Answer to Question #57639 in C++ for Sajid Mehmood (6)

Question #57639
Q. Write a program that inputs marks of ten students. The program displays the numbers of students in each grade. The criteria is as follows:
80 or above A
60 to 79 B
40 to 59 C
Below 40 F
1
Expert's answer
2016-02-08T07:37:35-0500
#include <iostream>

using namespace std;

int main()
{
/*
** Each item is a grade (A, B, C ,F), wich stores
** the number of students who received her
*/
uint32_t grades[4] = {0};

cout << "Enter student marks:" << endl;

uint32_t mark = 0;

for(uint32_t i = 0; i < 10; i++)
{
cin >> mark;

if ( mark >= 80 )
grades[0]++;
else if ( mark >= 60 )
grades[1]++;
else if ( mark >= 40 )
grades[2]++;
else
grades[3]++;
}

cout << "Students who have received: " << endl;
cout << "A - " << grades[0] << endl;
cout << "B - " << grades[1] << endl;
cout << "C - " << grades[2] << endl;
cout << "F - " << grades[3] << endl;

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS