Wednesday, November 4, 2015
C++ Program To Calculate The Average For 10 Students In 5 Courses
Tracing through the program we have the predecessor directives, next is declarations. The identifer 'nos' specifies the number of students. Then 'noc' the number of courses. 'Score' is declared as an array, while 'sum' and 'ave' as integers.
#include <iostream.h>
#include <conio.h>
void main ()
{
const int nos=10;
const int noc=5;
char name [nos];
float scores [nos][noc];
float sum[nos], ave[nos];
int i,j;
for (i=1;i<nos; i++)
{
cout<<"Enter name of student: "<<i<<endl;
cin>>name;
for(j=1;j<=noc;j++)
{
cout<<" enter the score: "<<j<<endl;
cin>> score[i][j];
sum[i]=score[i][j];
}
ave[i]=sum[i]/5;
cout<<"Average Score For"<<" "name<<" "<<ave[i]<<endl;
}
}
Labels:
C++,
Computer Programming,
Programming