Created
September 9, 2014 04:06
-
-
Save raydvard/eb3479ed02c55d907857 to your computer and use it in GitHub Desktop.
C++
This file contains 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
//###################### 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