Program in C++ to find the reverse of a given number
#include<iostream> #include<conio.h> using namespace std; int main() { int n; cout<<"Enter a number:-"; cin>>n; int rev=0; while(n>0) { rev=n%10+rev*10; n/=10; } cout<<"Reverse ="<<rev; getch(); }Output:-
Program in C++ to find the reverse of a given number using Function
#include<iostream> #include<conio.h> using namespace std; int Reverse(int n) { int rev=0; while(n>0) { rev=n%10+rev*10; n/=10; } return (rev); } void main() { int x; cout<<"Enter a number:-"; cin>>x; cout<<"Reverse ="<<Reverse(x); getch(); }Output:-
0 Comments