Sum of Digits in C Programming
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=0,r,i;
printf("\n Sum Of Digits ");
printf("\n ************ ");
printf("\n Enter a Value : ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("\n Sum Value is : ",sum);
getch();
}
Output
No comments:
Post a Comment