Write the program- QBASIC
To store three different numbers under three different variables then find their sum and average.
Answers
Answered by
0
The program,
To store three different numbers under three different variables then find their sum and average is as follows.
#include<stdio.h>
int main()
{
// declare variable
float num1, num2, num3;
float sum, avg;
// take inputs
printf("Enter three Numbers: ");
scanf("%f %f %f",&num1, &num2, &num3);
// calculate sum
sum = num1 + num2 + num3;
// calculate average
avg = sum / 3;
// display entered numbers
printf("Entered numbers are: %.2f, %.2f and %.2f\n",
num1, num2, num3);
// display sum and average
printf("Sum=%.2f\n", sum);
printf("Average=%.2f\n",avg );
return 0;
}
Similar questions