Please explain this code: #include # define SIZE 30 using namespace std; int main() { int stud_test[SIZE]; int index_stud; int r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0,r8=0; cout<<"Please enter the number of students: "; cin>>index_stud; //input for(int i=0;i
Please explain this code:
#include<iostream>
# define SIZE 30
using namespace std;
int main()
{
int stud_test[SIZE];
int index_stud;
int r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0,r8=0;
cout<<"Please enter the number of students: ";
cin>>index_stud;
//input
for(int i=0;i<index_stud;i++)
{
cout<<"Enter the marks: ";
cin>>stud_test[i];
}
for(int i=0;i<index_stud;i++)
{
if((stud_test[i]>=0) && (stud_test[i]<=24) )
r1=r1+1;
else if((stud_test[i]>=25) && (stud_test[i]<=49))
r2=r2+1;
else if((stud_test[i]>=50) && (stud_test[i]<=74))
r3=r3+1;
else if((stud_test[i]>=75) && (stud_test[i]<=99))
r4=r4+1;
else if((stud_test[i]>=100) && (stud_test[i]<=124))
r5=r5+1;
else if((stud_test[i]>=125) && (stud_test[i]<=149))
r6=r6+1;
else if((stud_test[i]>=150) && (stud_test[i]<=174))
r7=r7+1;
else if ((stud_test[i]>=175) && (stud_test[i]<=200))
r8=r8+1;
}
cout<<"Number of students which lie in 00-24: "<<r1<<endl;
cout<<"Number of students which lie in 25-49: "<<r2<<endl;
cout<<"Number of students which lie in 50-74: "<<r3<<endl;
cout<<"Number of students which lie in 75-99: "<<r4<<endl;
cout<<"Number of students which lie in 100-124: "<<r5<<endl;
cout<<"Number of students which lie in 125-149: "<<r6<<endl;
cout<<"Number of students which lie in 150-174: "<<r7<<endl;
cout<<"Number of students which lie in 175-200: "<<r8<<endl;
}
Step by step
Solved in 2 steps