Skip to content

Instantly share code, notes, and snippets.

@raydvard
Created September 9, 2014 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raydvard/e63019a2c8c5e343e66b to your computer and use it in GitHub Desktop.
Save raydvard/e63019a2c8c5e343e66b to your computer and use it in GitHub Desktop.
C++
//###################### Prac-4 ########################## //
// Input an integer number and output the given number in reverse between last two digits //
// ####################################################### //
#include <stdio.h>
int main()
{
int num;
int fd, sd, td;
printf("Please input an integer number: ");
scanf("%d", &num);
td = num % 10; // Logic to output last digit of any integer number is to find out the reminder !!
num = num / 10; // then i have divide by 10 that given number to make that number 10 place downward !!
sd = num % 10; // then again find out the reminder of that new number to output last digit of that new number !!
num = num / 10; // and so on
fd = num % 10;
printf("\nThe Reverse number of the given number is: %d%d%d", td, fd, sd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment