clanguage07@gmail.com

clanguage07@gmail.com

Saturday, June 16, 2012

Write a C program to find the sum of individual digits of a positive integer.

#include<stdio.h>
#include<conio.h>
void main()
{
int num, k=1, sum=0;
clrscr();
printf("Enter the number whose digits are to be added:");
scanf("%d",&num);
while(num!=0)
{
k=num%10;
sum=sum+k;
k=num/10;
num=k;
}
printf("Sum of the digits:%d",sum);
getch();
}

No comments:

Post a Comment

GET MORE INFORMATION

http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true