Last active
August 29, 2015 14:25
-
-
Save toanalien/a2db3b528f3172895b3a to your computer and use it in GitHub Desktop.
flip number function
This file contains hidden or 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
#include <stdio.h> | |
int flip_number(int n) | |
{ | |
int temp = 0; | |
while (n/10 !=0) | |
{ | |
temp += n%10; | |
temp*=10; | |
n = (n-n%10)/10; | |
} | |
temp+=n; | |
return temp; | |
} | |
int main() | |
{ | |
int a = 12345; | |
printf("%d", flip_number(a)); | |
} | |
// output: 54321 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment