Question: Please write code in C and please add comments Questions Write a loop based C program that takes a positive number as input from the

Please write code in C and please add comments
Questions
Write a loop based C program that takes a positive number as input from the user via the
keyboard and calculates the sum of all the individual digits in that number. Display the
result. Note that if the user enters a negative number, your program must keep asking the
user until a valid number is entered. Below are some sample outputs for how the program
should behave. Note that the input number is not necessarily 5-digit.
Sample Run 1:
Enter a positive nubmber: 38912
Sum of all digits in 38912 is 23
Sample Run 2:
Enter a positive nubmber: 432
Sum of all digits in 432 is 9
Sample Run 3:
Enter a positive nubmber: -278239
You entered an invalid number
Re-enter the number: -3456
You entered an invalid number
Re-enter the number: 123456
Sum of all digits in 123456 is 21
Please write code in C and please add comments

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!