Q:

Calculate a students average in ten subjects using c++

0

Write a program to calculate a student's average in ten subjects and calculate the standard deviation for each subject

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
# include <iomanip>
using namespace std;
int main(){
long int mark[10] ;
int count , n ;
float aver , d[10] , sum = 0 ;
cout << " Enter the number of subjects : " ;
cin >> n ;
for ( count = 0 ; count <n ; count ++ )
{
cout << " Enter the mark [ " << count << " ] = " ;
cin >> mark[ count ] ;
sum += mark[ count ] ;
}
aver = sum / n ;
cout<< " \n \t Average = " << aver ;
cout<<"\n \t mark \t Standard Deviation";
cout<< "\n \t ------\t -----------------------";
for (count=0;count<n;count++)
{
d[count]=mark[count]-aver;
cout<<"\n \t "<<mark[count]<<"\t"<<d[count];
}
}

 

Output:

Enter the number of subjects :10
Enter the mark[0]=89
Enter the mark[1]=78
Enter the mark[2]=65
Enter the mark[3]=55
Enter the mark[4]=78
Enter the mark[5]=66
Enter the mark[6]=61
Enter the mark[7]=73
Enter the mark[8]=64
Enter the mark[9]=53
Average=68.2
Mark   Standard Deviation
------  -----------------------
89         20.80
78          9.80
65          -3.20
55          -13.20
78          9.80
66          -2.20
61          -7.20
73          4.80
64          -4.20
53          -15.20

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Find largest number between two numbers using c++... >>
<< Display the largest Element of an array using c++...