Answer to Question #188275 in C for Anjali Siriah

Question #188275

Accept 10 numbers from the user and calculate their sum.


1
Expert's answer
2021-05-02T13:00:24-0400
#include <stdio.h>

int main()
{
    int i, sum;
    
    printf("Enter 10 numbers: ");

    sum = 0;
    for(i = 0; i < 10; ++i)
    {
        int tmp;
        if(scanf("%d", &tmp) != 1)
        {
            printf("Bad input\n");
            return 1;
        }

        sum += tmp;
    }
    
    printf("Sum is %d\n", sum);
    
    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