C++ Program To Calculate The Average For 10 Students In 5 Courses andrey понедельник, 4 августа 2014 г. No Comment

Computer science program using C++ language to calculate the sum and average of 10 students in 5 different courses. Note that c++ is case sensitive. There are two loops in this program. The first loop to read in the names of 10 students and the second loop which is within the first loop is to read in the scores in each courses. The first loop is incremented when the second inner loop is completed.

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 
#include
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;
}
}
Computer science program using C++ language to calculate the sum and average of 10 students in 5 different courses. Note that c++ is case sensitive. There are two loops in this program. The first loop to read in the names of 10 students and the second loop which is within the first loop is to read in the scores in each courses. The first loop is incremented when the second inner loop is completed.

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 
#include
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;
}
}
by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment