#include<conio.h>
#include<stdio.h>
void main()
{
int i,m=0,a,num,sum=0;
clrscr();
printf("\n\n\t\t Enter the number: ");
scanf("%d",&num);
while(num>9)
{
sum=0;
while(num>0)
{
m=num%10;
num=num/10;
sum=sum+m;
}
num=sum;
}
printf("\n\n\t\t Sum of digits is: %d",sum);
getch();
}
#include<stdio.h>
void main()
{
int i,m=0,a,num,sum=0;
clrscr();
printf("\n\n\t\t Enter the number: ");
scanf("%d",&num);
while(num>9)
{
sum=0;
while(num>0)
{
m=num%10;
num=num/10;
sum=sum+m;
}
num=sum;
}
printf("\n\n\t\t Sum of digits is: %d",sum);
getch();
}
No comments:
Post a Comment