Question:C program to calculate sum of digits
Answer
#include<stdio.h> int main(){ int num,sum=0,r; printf("Enter a number: "); scanf("%d",&num); while(num){ r=num%10; num=num/10; sum=sum+r; } printf("Sum of digits of number: %d",sum); return 0; }Sample output: Enter a number: 123 Sum of digits of number: 6
+ ExplanationNot Moderated
+ Report
C program to calculate sum of digits