/*
This prog is tested on Dev-c++ 4.9.9.-
Question : Sessional # 1
Group : 'A'
*/
#include <cstdlib>
#include <iostream>
#include <ctime>
#define row 10
#define col 4
using namespace std;
int main(int argc, char *argv[])
{
int marks[10][4]={0};
int lowest=0,highest=0;
int a[6]= {0,0,0,0,0,0},i,j;
srand(time(NULL));
for(i=0 ; i < row ; i++ )
{
for(j=0 ; j < col-1 ; j++ )
{
marks[i][j] = rand()%51+50;
}
}
lowest = marks[i][0];
for(i=0 ; i < row ; i++ )
{
for(j=0 ; j < col-1 ; j++ )
{
if(lowest > marks[i][j])
lowest = marks[i][j];
if(highest < marks[i][j])
highest = marks[i][j];
}
}
for(i=0 ; i < row ; i++ )
{ for(j=0 ; j < col-1 ; j++ )
{
marks[i][col-1] += marks[i][j];
}
marks[i][col-1] /= col-1;
}
for(i=0 ; i < row ; i++ )
{ for(j=0 ; j < col-1 ; j++ )
{
if(marks[i][j] == 100)
a[5]++;
else if(marks[i][j] >= 90)
a[4]++;
else if(marks[i][j] >= 80)
a[3]++;
else if(marks[i][j] >= 70)
a[2]++;
else if(marks[i][j] >= 60)
a[1]++;
else if(marks[i][j] >= 50)
a[0]++;
}
}
cout << "\tTest1\tTest2\tTest3\tAverage" << endl;
for(i=0 ; i < row ; i++ )
{
cout << i+1 << "\t";
for(j=0 ; j < col ; j++ )
{
cout << marks[i][j] << "\t" ;
}
cout << endl;
}
cout << "\n\n\nLowest grade " << lowest << endl;
cout << "Highest grade " << highest << endl;
cout << "\n\nGrade Distribution : \n\n"<< endl;
for(i=0 ; i < 6 ; i++ )
{
cout << 50+(i*10) ;
if(59+(i*10)<100)
cout << "-" << 59+(i*10) ;
cout << ":\t";
for(j = 0 ; j < a[i] ; j++)
cout << "*" ;
cout << endl;
}
cout << endl; cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}