Answer to Question #293953 in C for Prathamesh

Question #293953

Input numbers from the user and find the sum of all those input numbers until the user inputs zero. In other means, the loop should end when the user enters 0. Finally, display the sum of all those numbers entered by the user


1
Expert's answer
2022-02-07T17:10:02-0500
#include <stdio.h>


int main() {
    int sum = 0;
    int num;


    while (1) {
        printf("Enter an integer number (zero to terminate) ");
        scanf("%d", & num);
        if (num == 0) {
            break;
        }
        sum += num;
    }
    printf("The sum of entered 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