Writing the command for getting the average of three numbers.

Hi guys, so this is what I've been working on. Our assignment is to write a program that the user will enter his 1st quiz, 2nd quiz and 3rd quiz, then after the total sum of all quizzes, it will display the sum and the average of the 3 quizzes. Here's the output:

Output:
Enter 1st Quiz Score: 12
Enter 2nd Quiz Score: 19
Enter 3rd Quiz Score: 9

The sum is 40.
The average is 13.

I'm very new to this stuff and would appreciate for your suggestions. Thanks!
BTW, this is the program I made and I don't know if I did it right.

#include<stdio.h>
int n1,n2,n3,sum;
main()
{
printf("Enter 1st quiz number");
scanf("%d",&n1);
printf("Enter 2nd quiz number");
scanf("%d",&n2);
printf("Enter 3rd quiz number");
scanf("%d",&n3);
sum=n1+n2+n3;
print("The sum is %d",sum);
getche();
}

Try putting your code in code tags.

The current program wouldn't compile in its current form. You have missed the f from printf when displaying the sum. Furthermore, the output can't be the actual output as there is no code to calculate the average.

To calculate the average, total all numbers together, then divide by the quantity of numbers (in this case 3).

Topic archived. No new replies allowed.