C program to find the sum of digit of a number.
code👇👇👇👇👇👇👇👇👇
#include<stdio.h>
int main()
{
int n, r, sum = 0;
printf("Enter a number: ");
scanf("%d", &n);
while(n != 0)
{
r = n % 10;
sum += r;
n = n / 10;
}
printf("sum = %d", sum);
return 0;
}
output |
No comments:
Post a Comment