THX ladybird u helped me ALOT..
I really appreciate it ..
This is the program after correction and I add things :
Code:
#include <iostream>
#include <conio>
int main()
{
int ID [20];
int score [20];
int i,j;
int low=score[0];
int high=score[0];
int sum=0 ;
int d1 , d2 , d3 ;
int sum1 , sum2 , sum3 , sum4, z , q ;
float Avg ;
for (i=0;i<20;i++)
{
cout<<"Enter Student "<< (i+1) << " ID: "<<endl;
cin>> ID[i];
cout<<"Enter Studet " << (i+1) << "score: "<<endl;
cin>> score[i];
sum+=score[i];
d1=ID[i]/100000000;
ID[i]%=100000000;
d2=ID[i]/10000000;
ID[i]%=10000000;
d3=ID[i]/1000000;
ID[i]%=1000000;
if(d3==9)
sum1+=i;
if(d3==8)
sum2+=i;
if(d3==7)
sum3+=i;
if(d3==6)
sum4+=i;
}
for(j=0;j<20;j++)
{
if (score[j]<=100 && score[j]>=90)
cout<<"Student :" << ID[j] <<" score is " <<(score[j])
<< " and the grade is " <<'A'<< endl;
else
if (score[j]<90 && score[j]>=80)
cout<<"Student :" << ID[j] << " score is " << (score[j])
<< " and the grade is " <<'B'<<endl;
else
if (score[j]<80 && score[j]>=70)
cout<<"Student :" << ID[j]<< " score is " << (score[j])
<< " and the grade is " <<'C'<<endl;
else
if (score[j]<70 && score[j]>=60)
cout<<"Student :" << ID[j]<< " score is " << (score[j])
<< "and the grade is " <<'D'<<endl;
else
if (score[j]<60)
cout<<"student :" <<ID[j] << " score is " << (score[j])
<< " and the grade is " <<'F'<<endl;
Avg= sum/20;
if ( score[j]>=Avg )
z+=i;
else
q+=i;
}
for(int n=1; n<20; n++)
{
if ( score[n]>high)
high=score[n];
if (score[n]<low)
low=score[n];
}
cout<< "The Highest score is :" << high << " Assigned to " <<ID[j] << " Student" <<endl;
cout<< "The lowest score is :" << low << " Assigned to " << ID[j] << " Student" <<endl;
cout<< endl << endl;
cout<<"Average = "<<Avg << endl;
cout<< "The number of students that got score bigger than or egual Avg =" << z << endl;
cout<< "The number of students that got score less than Avg ="<< q << endl;
cout<< "The number of students from level 29 are :" << sum1 << endl;
cout<< "The number of students from level 28 are :" << sum2 << endl;
cout<< "The number os students from level 27 are :" << sum3 << endl;
cout<< "The number of students from level 26 are :" << sum4 << endl;
getch ();
return 0;
}
The problem is the Outputs in my program are garbage .. so I don't if its true or not .. (If there is a way to correct it tell me plz ) ..
I want to know how many students from each level .. Is there any mistakes ??