Wednesday, September 9, 2009
FIND OUT GENERIC ROOT OF A NUMBER USING C PROGRAM
void main(){ long int num,sum,r; clrscr(); printf("\nEnter a number:-"); scanf("%ld",&num); while(num>10) { sum=0; while(num) { r=num%10; num=num/10; sum+=r; } if(sum>10) num=sum; else break; } printf("\nSum of the digits in single digit is: %ld",sum); getch()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment