Calculate the highest, lowest and average mark key in by user.
This is the example to calculate the highest, lowest and average mark key in by user.
this program also count the number of student who get A,B,C,D or E from
the information key in by the user.
Sample Output:
This is the example to calculate the highest, lowest and average mark key in by user.
this program also count the number of student who get A,B,C,D or E from
the information key in by the user.
Sample Output:
Source code:
#include <iostream>
using namespace std;
int main(){
cout<< "\nStatistic of Class Performance\n\n";
int markA = 0,markB = 0,markC = 0,markD = 0,markE = 0;
int max = 0, min = 0;
double num[10],sum=0.0,average;
for(int i=0; i<10 ; i++)
{
cout<<"\tEnter mark student "<<i+1<<" : ";
cin>>num[i];
if(num[i] >= 80 && num[i] <= 100)
{
markA = markA +1 ;
}
else if(num[i] >= 70 && num[i] <= 79)
{
markB = markB+1;
}
else if(num[i] >=50 && num[i] <=69)
{
markC = markC+1;
}
else if(num[i] >=40 && num[i] <= 49)
{
markD= markD+1;
}
else
{
markE= markE+1;
}
sum+=num[i];
}
max = num[0];
min = num[0];
for(int i=0; i<10 ; i++)
{
if(num[i]>max)
{
max = num[i];
}
else
{
max = max;
}
if(num[i]<min)
{
min = num[i];
}
else
{
min = min;
}
}
cout<<endl<<"\tGrade"<<"\tThe Number Of Students"<<endl;
cout<<"\tA\t"<<markA<<endl;
cout<<"\tB\t"<<markB<<endl;
cout<<"\tC\t"<<markC<<endl;
cout<<"\tD\t"<<markD<<endl;
cout<<"\tE\t"<<markE<<endl;
/* Tamat Display */
cout<<endl<<"\tThe Highest mark : "<<max<<endl;
cout<<"\tThe Lowest mark : "<<min<<endl;
average=sum/30;
cout<<"\tThe Average mark : "<<average<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
cout<< "\nStatistic of Class Performance\n\n";
int markA = 0,markB = 0,markC = 0,markD = 0,markE = 0;
int max = 0, min = 0;
double num[10],sum=0.0,average;
for(int i=0; i<10 ; i++)
{
cout<<"\tEnter mark student "<<i+1<<" : ";
cin>>num[i];
if(num[i] >= 80 && num[i] <= 100)
{
markA = markA +1 ;
}
else if(num[i] >= 70 && num[i] <= 79)
{
markB = markB+1;
}
else if(num[i] >=50 && num[i] <=69)
{
markC = markC+1;
}
else if(num[i] >=40 && num[i] <= 49)
{
markD= markD+1;
}
else
{
markE= markE+1;
}
sum+=num[i];
}
max = num[0];
min = num[0];
for(int i=0; i<10 ; i++)
{
if(num[i]>max)
{
max = num[i];
}
else
{
max = max;
}
if(num[i]<min)
{
min = num[i];
}
else
{
min = min;
}
}
cout<<endl<<"\tGrade"<<"\tThe Number Of Students"<<endl;
cout<<"\tA\t"<<markA<<endl;
cout<<"\tB\t"<<markB<<endl;
cout<<"\tC\t"<<markC<<endl;
cout<<"\tD\t"<<markD<<endl;
cout<<"\tE\t"<<markE<<endl;
/* Tamat Display */
cout<<endl<<"\tThe Highest mark : "<<max<<endl;
cout<<"\tThe Lowest mark : "<<min<<endl;
average=sum/30;
cout<<"\tThe Average mark : "<<average<<endl;
return 0;
}

0 comments:
Post a Comment