We can reverse a number in C++ using arithmetic operators. In this program, we are getting number as input from the user and reversing that number.
REVERSE THE INTEGER
#include<iostream>
using namespace std;
int main()
{
int n,reverse=0;
cout<<"Input value to reverse:";
cin>>n;
while(n!=0)
{
reverse=reverse*10;
reverse=reverse+n%10;
n=n/10;
}
cout<<"Reverse integer:";
cout<<reverse;
return 0;
}
OUTPUT:
BY
REGU RAM SV.
Super bro
ردحذفإرسال تعليق