Skip to content

Instantly share code, notes, and snippets.

@0x000000AC
Created June 8, 2015 03:07
Show Gist options
  • Save 0x000000AC/2995dd78ae628af13495 to your computer and use it in GitHub Desktop.
Save 0x000000AC/2995dd78ae628af13495 to your computer and use it in GitHub Desktop.
Reversing an Int in a While() loop
#include <stdio.h>
int main(void)
{
int number, right_digit;
printf ("Enter your number.\n");
scanf ("%i", &number);
while ( number != 0 )
{
right_digit = number % 10;
printf ("%i", right_digit);
number = number / 10;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment