117k views
5 votes
The average of three numbers, value1, value2, and value3, is given by (value1 + value2 + value3)/ 3.0. Write a program that reads double variables value1, value2, and value3 from the input, respectively, and computes averageOfThree using the formula. Then, outputs "Average is " followed by the value of averageOfThree to four digits after the decimal point. End with a newline.

Ex: If the input is 2.25 2.0 1.75, then the output is:


Average is 2.0000
Please help!

User Kevingoos
by
7.7k points

1 Answer

1 vote

Answer:

#include <stdio.h>

int main(void) {

double value1, value2, value3;

double averageOfThree;

/* Read 3 double values */

scanf("%lf %lf %lf", &value1, &value2, &value3);

/* Compute the average */

averageOfThree = (value1 + value2 + value3) / 3.0;

/* Output the average */

printf("Average is %.4lf\\", averageOfThree);

return 0;

}

User Dharminder
by
8.7k points