6. Program that inputs marks of ten students. The program displays the number of students in each grade.

Chapter 7: 

Arrays

Programming Exercise

Problem # 6:

Write a program that inputs marks of ten students. The program displays the number 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

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
    int arr[10], z, a, b, c, d;
    a=b=c=d=0;
    cout<<"Enter marks of ten students:";
    for(z=0;z<10;z++)
    {
        cin>>arr[z];
            if(arr[z]>=80)
            {
                cout<<"Grade is A.\n";
                a++;  
            }
             else if(arr[z]>60)
            {
                cout<<"Grade is B.\n";
                b++;  
            }
            else if(arr[z]>40)
            {
                cout<<"Grade is C.\n";
                c++;  
            }
            else
            {
                cout<<"Grade is F.\n";
                d++;
            }
    }
    cout<<"A grade is stored "<<a<<" times in the array."<<endl;
    cout<<"B grade is stored "<<b<<" times in the array."<<endl;
    cout<<"C grade is stored "<<c<<" times in the array."<<endl;
    cout<<"F grade is stored "<<d<<" times in the array."<<endl;
}

Output:


Let me know in the comment section if you have any question.

Previous Post:
5. program that inputs ten integers in an array. It displays the number of occurrences of each number in the array as follows: 3 is stored 4 times in the array. 1 is stored 1 times in the array.


Comments