It’s the sum of digits of the number C program that inputs any number from the user and calculate the sum of its digits, and print sum on the screen.
To understand this program, it’s better you should know the following topics:
Program (1): to find a sum of digits of the number.
#include<stdio.h> #include<conio.h> void main() { int rem,num; int sum=0; printf("Enter a number (upto 3 digits):- "); scanf("%d",&num); while(num>0) { rem=num%10; sum=sum+rem; num=num/10; } printf("The sum of digits of enter number is %d",sum); getch(); }
Output (1)
Enter a number (upto 3 digits):- 143 The sum of digits of enter number is 8