Computer Science, asked by WeningNM3085, 10 months ago

C++ program to implement the function is reverse number to check, if given positive are the same numbers are reversed

Answers

Answered by loyananda12
0

I don't know answer you can search on photo computer app

all the best

please mark brilliant

Answered by tiger009
0

Reverse Number

Output:

Enter Number: 16261

Same number after reverse.

Explanation:

#include <iostream>  

using namespace std;  

//define class

class reverse

{

 public:

 //define function to check reverse number

 void Check_reverse(int n)

 {  

   int sum=0, num, r;

   num=n;

   while(n>0)    

   {    

     r=n%10;    

     sum=(sum*10)+r;    

     n=n/10;    

   }    

   if(num==sum)    

     cout<<"Same number after reverse.";    

   else    

    cout<<"Number is not similar.";    

}

};

//define main method to call the function

int main()  

{  

 int n;    

 cout<<"Enter Number: ";    

 cin>>n;    

 reverse obj;

 obj. Check_reverse(n);

 return 0;

}  

The following are the description of the program.

  • Define required header file and namespace, then define class 'reverse' inside it.
  • Define function 'Check_reverse()' and pass the argument 'n' and inside the function, we reverse the number and check that the following number is equal to the reversed number.
  • Finally, define the main method and inside it, we set the variable 'n' and get input from the user in it, then create the class object and call the following 'Check_reverse()' function through the object.

Learn More:

https://brainly.in/question/1389587

Similar questions