Write a program to calculation of sum of the digit
Program:
#include<stdio.h> #include<conio.h> void main() { int n,r,sum=0; printf("enter a number\n"); scanf("%d",&n); while(n>0) { r=n%10; sum=sum+r; n=n/10; } printf("sum of digit of entered number %d",sum); getch(); }
Output:
enter a number 420 sum of digit of entered number 6
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer