Write A C program to Find the sum of digits using modular division
#include<stdio.h>
int main()
{
int n,sum=0,m;
printf("Enter a number: ");
scanf("%d", &n);
while(n>0)
{
m=n%10;
sum=sum+m;
n=n/10;
}
printf("sum=%d", sum);
return 0;
}
Comments
Post a Comment