Answer to Question #319678 in C for Sami

Question #319678

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


1
Expert's answer
2022-03-31T13:07:08-0400
#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;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS