#include<stdio.h>
main()
{
int num,sum=0;
printf("\nEnter a number=");
scanf("%d",&num);
while(num)
{
sum=sum+num%10;
num/=10;
}
printf("\nThe sum =%d",sum);
}
main()
{
int num,sum=0;
printf("\nEnter a number=");
scanf("%d",&num);
while(num)
{
sum=sum+num%10;
num/=10;
}
printf("\nThe sum =%d",sum);
}
No comments:
Post a Comment