Created
April 16, 2015 18:52
-
-
Save shohan4556/c4e4726ecea54855af94 to your computer and use it in GitHub Desktop.
UVA 11332 (summing digit ) solution in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Author : Shohanur Rahaman | |
//Problem level : Easy | |
//UVA : 11332 (Summing Digits) | |
#include <stdio.h> | |
int main() | |
{ | |
int t; | |
long long int n; | |
while(scanf("%lld",&n)==1){ | |
if(n==0) | |
break; | |
t=0; | |
while(1){ | |
while(n!=0){ | |
t=t+(n%10); | |
n=n/10; | |
} | |
if(t/10==0) | |
break; | |
else{ | |
n=t; | |
t=0; | |
} | |
} | |
printf("%d\n",t); | |
} | |
return 0; | |
} |
Thank you so much sir. This solution is so easy to understand.
thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much sir. This solution is so easy to understand.