Answer to Question #128828 in C for kern

Question #128828
I need a program that takes many numbers from the user and returns their sum.
1
Expert's answer
2020-08-11T12:50:17-0400
#include <stdio.h>

int main()
{
    int n, i, num, sum = 0;
    printf("How many numbers? ");
    scanf("%d", &n);
    for(i=0; i<n; ++i)
    {
        printf("Enter number %d: ", i+1);
        scanf("%d", &num);
        sum += num;
    }
    printf("Sum of the numbers 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