Write a program that declare an array of size 25 consisting of students’ test scores in the range 0–200. The user may input any score in the array. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157)
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
using namespace std;
/*
Write a program that declare an array of size 25 consisting of students’ test scores in the range 0–200.
The user may input any score in the array. It should then determine the number of students having scores in
each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200.
Output the score ranges and the number of students. (Run your program with the following input data:
76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157)
*/
int main()
{
int Scores[] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157};
int l,n,Students[8];
for(n=0;n<8;n++) Students[n]=0;
l = sizeof(Scores)/sizeof(Scores[0]);
cout<<"\n\tTotalNo. of Students = "<<l<<"\n";
for(n=0;n<l;n++)
{
if(Scores[n]<=24) Students[0] = Students[0]+1;
if(Scores[n]>=25 && Scores[n]<=49) Students[1] = Students[1]+1;
if(Scores[n]>=50 && Scores[n]<=74) Students[2] = Students[2]+1;
if(Scores[n]>=75 && Scores[n]<=99) Students[3] = Students[3]+1;
if(Scores[n]>=100 && Scores[n]<=124) Students[4] = Students[4]+1;
if(Scores[n]>=125 && Scores[n]<=149) Students[5] = Students[5]+1;
if(Scores[n]>=150 && Scores[n]<=174) Students[6] = Students[6]+1;
if(Scores[n]>=175 ) Students[7] = Students[7]+1;
}
cout<<"\n\tNo. of Students with Score from 0 - 24 (inclusive) = "<<Students[0];
cout<<"\n\tNo. of Students with Score from 25 - 49 (inclusive) = "<<Students[1];
cout<<"\n\tNo. of Students with Score from 50 - 74 (inclusive) = "<<Students[2];
cout<<"\n\tNo. of Students with Score from 75 - 99 (inclusive) = "<<Students[3];
cout<<"\n\tNo. of Students with Score from 100 - 124 (inclusive) = "<<Students[4];
cout<<"\n\tNo. of Students with Score from 125 - 149 (inclusive) = "<<Students[5];
cout<<"\n\tNo. of Students with Score from 150 - 174 (inclusive) = "<<Students[6];
cout<<"\n\tNo. of Students with Score from 175 - 200 (inclusive) = "<<Students[7];
return(0);
}
Comments
Leave a comment