#include <stdio.h>
int main(int argc, char *argv[])
{
float num1 = 0;
float num2 = 0;
float num3 = 0;
float sum = num1 + num2 + num3;
float average = sum / 3;
printf("Enter three numbers:\n"); //Enter three floats
scanf("%f %f %f", &num1, &num2, &num3); //Assign to num1, num2, num3
printf("The sum of these three numbers is %f.\n", sum);//Print sum
printf("The average of these numbers is %f.\n", average);//Print average
}
これが表示されます。
Enter three numbers:
12.0
10.0
12.0
The sum of these three numbers is 0.000000.
The average of these numbers is 0.000000.