C Program To Find The Sum of Digits of An IntegerC Program To Find The Sum of Digits of An Integer

#include<conio.h>
#include<stdio.h>

void main()
{
int n,i,sum=0,rem;
printf("Enter Any Number  : ");
scanf("%d",&n);

for(i=n;n>0;(n=n/10))
{
rem=n%10;
sum=sum+rem;

}

printf("\n Sum  : %d",sum);

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment