➽ Program:-
#include<stdio.h>
int main()
{
long num, digit, sum
= 0, temp;
printf("Enter
the Number: ");
scanf("%ld", &num);
temp = num;
while(num > 0)
{
digit = num % 10;
sum = sum + digit;
num /= 10;
}
printf("Sum of
the Digits of %ld = %ld", temp, sum);
return 0;
}
➽ Output:-
Enter the Number: 456789
Sum of the Digits of 456789 = 39
0 Comments
Please do not enter any spam link in the comment section.