One dimensional array in C and C++ to store name and marks of 3 subject
C and C++Home

One dimensional array in C and C++ to store name and marks of 3 subject.

Assignment – 1 :

One dimensional array in C and C++ to store name of student and marks of Three subject. and give output in total, average marks of student and whole class.


A teacher needs a program to record marks for a class of 30 students who have sat three
computer
science tests.
Write and test a program for the teacher.

  • Your program must include appropriate prompts for the entry of data.
  • Error messages and other output need to be set out clearly and understandably.
  • All variables, constants and other identifiers must have meaningful names
    You will need to complete these three tasks. Each task must be fully tested.

You will need to complete these three tasks. Each task must be fully tested.

TASK 1 – Set up arrays:

Set-up one dimensional arrays to store:
• Student names
• Student marks for Test 1, Test 2 and Test 3
o Test 1 is out of 20 marks
o Test 2 is out of 25 marks
o Test 3 is out of 35 marks
• Total score for each student
Input and store the names for 30 students. You may assume that the students’ names are
unique.
Input and store the students’ marks for Test 1, Test 2 and Test 3. All the marks must be
validated on
entry and any invalid marks rejected.

TASK 2 – Calculate:

Calculate the total score for each student and store in the array.
Calculate the average total score for the whole class.
Output each student’s name followed by their total score.
Output the average total score for the class.

TASK 3 – Select:

Select the student with the highest total score and output their name and total score.

Output of above Question:

One dimensional array in C and C++ to store name and marks of 3 subject
One dimensional array in C and C++ to store name and marks of 3 subject
Screen shot of output:
One dimensional array in C and C++ to store name  of student and marks of 3 subject
One dimensional array in C and C++ to store name of student and marks of 3 subject

Answer for One dimensional array in C and C++ to store name and marks of 3 subject.

View answer on youtube chanel

#include <iostream>
#include <string>
using namespace std;

int main()
{   
    int count = 5; // set number of student as you want
    string students[count]; // holds the number of students in array eg: (Kishan, Nashib, Laxman)

cout << "------------------------------------------" << endl;
cout << "-- Welcome to Student Management System --" << endl;
cout << "------------------------------------------" << endl;

cout << "\nEnter the name of the students: " << endl;
for (int i = 0; i < count; i++) //4 i++ (1 incr)
{
    cout << "Name Of Student " << i + 1 << ": ";
    getline(cin,students[i]);
}

//For test 1
double test1Arr[count];
cout << "\n*** Test 1 Marks (out of 20) ***" << endl;
for (int i = 0; i < count; i++)
{
    cout << "Enter Marks obtained by " << students[i] << " : ";
    cin >> test1Arr[i];     
}


//For test 2
double test2Arr[count];
cout << "\n*** Test 2 Marks (out of 25) ***" << endl;
for (int i = 0; i < count; i++)
{
    cout << "Enter Marks obtained by " << students[i] << " : ";
    cin >> test2Arr[i];     
}


//For test 3
double test3Arr[count];
cout << "\n\n*** Test 3 Marks (out of 35) ***" << endl;
for (int i = 0; i < count; i++)
{
    cout << "Enter Marks obtained by " << students[i] << " : ";
    cin >> test3Arr[i];     
}

//Storing total of each student and adding in array
double eachTotalMarksArray[count];
for (int i = 0; i < count; i++)
{
    eachTotalMarksArray[i] = test1Arr[i]+test2Arr[i]+test3Arr[i];       
}

//{100,100,80}

//Calculating  average total score for whole class
double TotalMarks = 0;
for (int i = 0; i < count; i++)
{
    TotalMarks = TotalMarks + eachTotalMarksArray[i];       
}
double averageTotalMarks = TotalMarks/count;

cout << "\nTotal Marks Obtained By Each Students: " << endl;
for(int i = 0; i < count; i++) {
    cout << students[i] << " : " << eachTotalMarksArray[i]  << endl;
}

cout << "\nAverage Total Score For The Class: " << averageTotalMarks << endl;    
return 0;


}

To Download Answer and code Click Below Button.

Download Answer and full code of One dimensional array in C and C++ to store name and marks of 3 subject.

Frequently Asked Question.

how to download free Car Rental System in Python Django with free Source Code?

Go to freeprojectscodes.com and search for project. You can get Different type of project. which is very useful for collage and school student.

Django Simple Projects with source code download.

Complete free Hospital Management System in Python Django with Source Code. download for free from freeprojectscodes

Free PHP projects With source code download.

Complete and fully working Student Project With Download Free Source code in freeprojectscode.com

To download  more Project Click Here

For Latest Information

For Latest Driver for computer and printer.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO
Translate »