Write a C program which will take numbers from the keyboard until the sum of these numbers is greater than 100 . On monitor display the sum min and average of numbers
#include <stdio.h>
int main()
{
int sum, min, num , n;
float avg;
sum = 0;
n = 0;
printf("Enter number: ");
scanf("%d", &num);
sum = sum + num;
min = num;
n++;
while (sum <= 100)
{
printf("Enter number: ");
scanf("%d", &num);
sum = sum + num;
n++;
if (min > num)
{
min = num;
}
}
avg = sum / n;
printf("\nSum: %d", sum);
printf("\nMin: %d", min);
printf("\nAverage: %.2f", avg);
printf("\nThe sum min and average of numbers: %.2f", (avg+min));
getchar();
return 0;
}
Comments
Leave a comment