Skip to content

Instantly share code, notes, and snippets.

@toanalien
Last active August 29, 2015 14:25
Show Gist options
  • Save toanalien/a2db3b528f3172895b3a to your computer and use it in GitHub Desktop.
Save toanalien/a2db3b528f3172895b3a to your computer and use it in GitHub Desktop.
flip number function
#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