Compute Average of Two Scores

Describe an algorithm to compute the average of two scores obtained by each of the 100 students

Questions by The_Kerr1431

Showing Answers 1 - 3 of 3 Answers

This can be done using structures

struct student
{
int score1;
int score2;
}st[5];

int sum,avg;
printf("Enter the first score:");
scanf{"%d",&st[i].score1);
printf("Enter the second score:");
scanf{"%d",&st[i].score2);
for(i=0;i<5;i++)
{
sum=st[i].score1+st[i].score2;
avg=sum/2;
printf("average=%d",&avg);
}

Shikhar Singhal

  • Jun 10th, 2013
 

Algorithm-

Let score1[100] and score2[100] be the arrays storing respective marks of the 100 students
let float avg[100] store the average of the respective students.

for n=0 to 99
avg[n]= (float(score1[n] +score2[n]))/ 2.0 //here 2.0 i simportant as it is used to get a floating point answer and not an integer value

  Was this answer useful?  Yes

HAkizimfura Yves

  • May 27th, 2014
 

write an algorithm that will display the sum of 5 integers by using two variables only
NB: do not use loops!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions