To calculate the sum of digits of an n digit number c programming
Answers
Answered by
1
The program output is also shown below.
* C program to accept an integer & find the sum of its digits.
long num, temp, digit, sum = 0;
printf("Enter the number \n");
scanf("%ld", &num);
temp = num;
while (num > 0)
digit = num % 10;
sum = sum + digit
Answered by
1
The program output is also shown below.
1)* C program to accept an integer & find the sum of its digits.
2) long num, temp, digit, sum = 0;
3) printf("Enter the number \n");
4) scanf("%ld", &num);
5) temp = num;
6)while (num > 0)
7) digit = num % 10;
8) sum = sum + digit
Similar questions