adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

program in c++ to find the reverse of a given number

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:-


Post a Comment

0 Comments