Skip to content

Instantly share code, notes, and snippets.

@raydvard
Created September 9, 2014 04:06
Show Gist options
  • Save raydvard/eb3479ed02c55d907857 to your computer and use it in GitHub Desktop.
Save raydvard/eb3479ed02c55d907857 to your computer and use it in GitHub Desktop.
C++
//###################### Prac-3 ########################## //
// Input an integer number and output the given number in reverse //
// ####################################################### //
#include <stdio.h>
int main()
{
int num;
int fd, sd, td;
int rev;
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, sd, fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment