- 1
write program to enter the degrees of student in 5 exams and find the average and print level If deg<50 fail If deg>50 pass
enter the degrees of student in 5 exams and find the average and print level If deg<50 fail If deg>50 pass
1 Answer
+ 1
You should try by yourself first, it's standard if statement use. I use arrays and for statements for ease.
Only read the rest for help, checking or if you are not willing to do the work (in which case I'd rethink whatever your learning)
You want something like this:
int arr[5],x,sum,avg,pass,fail;
int main() {
//input scores
for (int i=0;i<=5;i++)
{cin>>x;
arr[i]=x;}
for (int i=0;i<5;i++)
{sum+=arr[i];
if (arr[i] > 50)
{pass+=1;}
else if (arr[i] < 50)
{fail+=1;}}
avg=sum/5;
cout<<"Student's that passed: "<<pass<<"\nStudent's that failed: "<<fail<<endl<<"Student Average: "<<avg;