171k views
1 vote
Write a program that reads in five test scores. The program should them calculate the average for the five tests and display the average using fixed formatting with one digit of precision.

User Noran
by
5.0k points

1 Answer

7 votes
Written in C
I'm a noob so it might not be the best code
The result will be displayed with one digit precision (one digit after the decimal point)

#include
int main(){
float q,qq,qqq,qqqq,qqqqq; //test results
printf("Enter five test scores. Separate them with slashes like 12/13/14\\");
scanf("%f/%f/%f/%f/%f",q,qq,qqq,qqqq,qqqqq);
average = (q+qq+qqq+qqqq+qqqqq)/5;
printf("The average of the five test scores is %.1f",average);
return 0;}
User Greg Lyon
by
5.3k points