Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Using C++ Codes) Exercise #1: Grades Distribution Write a program that prompts

ID: 3819354 • Letter: #

Question

(Using C++ Codes)

Exercise #1: Grades Distribution Write a program that prompts the user to enter grades of TEN students. The program then distributes the grades in different ranges (i.e. 0-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, 90-99) and prints a star in front of each category for each occurrence of the grade falling the corresponding range, as shown in the output given below Sample input/output: ter Marks for 10 Students 5 67 72 93 73 61 87 78 80 10-19: 20-29 30-39 40-49 0-59 60-69 70-79 90-99 rocess returned 0 C0x0> execution time 158.024 s ress any key to continue. nter Marks or 10 Students 41 57 63 52 73 95 77 81 89 85 0-9 0-19 0-29 0-39 140-49 0-59 60-69 70-79 80-89 0-99 rocess returned 0 C0x0 execution time 63.174 s ress any key to continue.

Explanation / Answer

#include<iostream>
using namespace std;

int main()
{
   //array declaration...
   long int grades[]={0,0,0,0,0,0,0,0,0,0};//to store the range values//
  
  
   int i,n;
   //prompting input..
   cout<<"Enter Marks for 10 Students ";
   while(i<10)
   {
       cin>>n;//reading numbers
       //finding in which category it falls...
       //and incrementing the value of that category
       if(n>=0 && n<=9)
       {
           grades[0]=grades[0]+1;  
       }
       else if(n>=10 && n<=19)
       {
           grades[1]=grades[1]+1;  
       }
       else if(n>=20 && n<=29)
       {
           grades[2]=grades[2]+1;  
       }
       else if(n>=30 && n<=39)
       {
           grades[3]=grades[3]+1;  
       }
       else if(n>=40 && n<=49)
       {
           grades[4]=grades[4]+1;  
       }
       else if(n>=50 && n<=59)
       {
           grades[5]=grades[5]+1;  
       }
       else if(n>=60 && n<=69)
       {
           grades[6]=grades[6]+1;  
       }
       else if(n>=70 && n<=79)
       {
           grades[7]=grades[7]+1;  
       }
       else if(n>=80 && n<=89)
       {
           grades[8]=grades[8]+1;  
       }
       else if(n>=90 && n<=99)
       {
           grades[9]=grades[9]+1;  
       }
       i++;
   }
  
   //printing output..
   i=0;
   int j;
   while(i<10)
   {
       cout<<10*i<<"-"<<10*i+9<<": ";
       j=0;
       while(j<grades[i])
       {
           cout<<"* ";  
           j++;
       }
       cout<<" ";
          
       i++;
   }
  
  
  
  
  
  
   return 0;
}

output:-

Enter Marks for 10 Students
55 67 72 93 73 61 87 78 77 80
0-9:
10-19:
20-29:
30-39:
40-49:
50-59: *
60-69: * *
70-79: * * * *
80-89: * *
90-99: *


Process exited normally.
Press any key to continue . . .