#include<stdio.h>
void main()
{
int num,sum=0,ld;
printf("Enter a five digit number =");
scanf("%d",&num);
ld=num%10;
num=num/10;
sum=sum+ld;
ld=num%10;
num=num/10;
sum=sum+ld;
ld=num%10;
num=num/10;
sum=sum+ld;
ld=num%10;
num=num/10;
sum=sum+ld;
ld=num%10;
num=num/10;
sum=sum+ld;
printf("sum of the digits =%d",sum);
}
Tags:
Basic C program