C++ Program to Reverse number using function

ad+1

In this program we will declare an integer and then will take input from user for the integer. After this we will pass the integer in function where we will find its reverse number.

 Program:

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com

 
#include<iostream>
using namespace std;

int reverse(int n);

int main()
{

 int n=0, result=0;

 cout<<"Enter Number: ";
 cin>>n;

 result=reverse(n);
 cout<<"Reverse number is: " <<result <<endl;

}

int reverse(int n)
{

 int temp=0, rev=0;

 while(n!=0)
 {
     temp=n%10;
     rev=(rev*10)+temp;
     n=n/10;
 }

 return rev;

}

Output:

8 comments: Leave Your Comments

  1. This code is helpful but I want some Example of C++ Programs;

    Print Star pattern in C++
    Print number pattern in C++
    Prime number program in C++
    Factorial Program in C++

    ReplyDelete
    Replies
    1. I think u may searching for this...this is the program to print star in the following pattern.
      * * * * *
      * * * *
      * * *
      * *
      *

      #include
      using namespace std;
      int main()
      { for (int i=5;i>=1;i--)
      {cout<<\n";
      }
      for (int j=i;j<=i;j++)
      {cout<<"*";
      }
      } return (0);
      }

      Delete
  2. Phenomenal Blog! I may want to thank for the endeavors you have produced in composing this post. I'm trusting the exact same best work from you down the road too.open afp file

    ReplyDelete
  3. If so, the best treatment is surgery, often with preop chemoradation. I would think this treatment would be available at any hospital.
    No doctor would give a prescription for anything without examining the patient, reviewing their records and getting a history and it certainly would not be a plant extract.

    solve your afp problems

    ReplyDelete
  4. thank you for sharing useful post.
    c++ programming tutorial
    welookups

    ReplyDelete
  5. *
    **
    ***
    ****
    ***** i am looking for this pattern code in c++

    ReplyDelete
    Replies
    1. #include
      using namespace std;
      int main()
      {
      for(int i=1;i<=5;i++)
      {
      for(int j=1;j<=i;j++)
      {
      cout << "*";
      }
      cout << endl;
      }
      return 0;
      }

      Delete
  6. Nice program . visit more good coding program collection Click Here

    ReplyDelete