Write a program which reads 20 real numbers and shows their sum and their multiplication.
Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
int main()
{
int i;
double x, sum, mult;
sum = 0;
mult = 1;
for(i=1;i<=20;i++)
{
printf("Enter number %2d : ",i);
scanf("%lf",&x);
sum+=x;
mult*=x;
}
printf("Sum = %.4lf\tMult = %.4lf\n",sum,mult);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Program output 11