/*
Name: WAP to add digits of entered number
Author: Parveen Malik
Date: 23/09/11 09:41
*/
#include <stdio.h>
#include <conio.h>
int main()
{
long num;
int sum=0,rem;
printf("Enter a number \n");
scanf("%ld",&num);
while(num!=0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
printf(" Sum of digits of entered number is : %d",sum);
getch();
return 0;
}
OUTPUT :
0 comments:
Post a Comment