Created
November 10, 2015 17:03
-
-
Save nalin-adh/eb178fa0cc221442ec11 to your computer and use it in GitHub Desktop.
A C++ program to reverse a number using function.
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
#include<iostream> | |
#include<conio.h> | |
using namespace std; | |
int rev(int n); | |
int main() | |
{ | |
int x; | |
cout<<"Enter any number to reverse it : ";cin>>x; | |
cout<<"\nThe reverse form of "<<x<<" is "<<rev(x); | |
getch(); | |
return(0); | |
} | |
int rev(int n) | |
{ int num; | |
while(n!=0) | |
{ | |
int r=n%10; | |
num=num*10+r; | |
n=n/10; | |
} | |
return(num); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment