#include
#include
#include
void main()
{
int n,s=0;
clrscr();
printf("\n\tEnter a Number:");
scanf("%d",&n);
printf("\n\tSum of Digits till a single digit\n\t%d",n);
for(;n!=0;)
{
s=s+n%10;
n=n/10;
if(n==0&&s>9)
{
printf("\n\t %2d",s);
n=s;
s=0;
}
}
printf("\n\t %2d",s);
getch();
}
No comments:
Post a Comment