Twitter Feed Facebook Google Plus Youtube

Adsense responsive

Recent Post below header

Thursday, 31 January 2013

C PROGRAM: TO FIND SUM OF DIGITS OF A NUMBER

CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,sum=0,n;
clrscr();
printf("Enter any integer value ");
scanf("%d",&num);
while(num>0)
{
 n=num%10;
 sum=sum+n;
 num=num/10;
}
printf("Sum of digits is = %d",sum);
getch();
}


CODING

OUTPUT


For any query or suggestion please comment below...

No comments:

Post a Comment