VILL- DEBANDI, AMTA, HOWRAH PIN-711410 Phone-9836357266
26. Sum of digits :—
#include<stdio.h>
int main()
{
int i,n,r,k,sum;
printf("enter value of n ");
scanf("%d",&n);
sum=0,k=n;
while(n>0)
r=n%10;
n=n/10;
sum=sum+r;
}
printf("%d",sum);
return 0;
No comments:
Post a Comment