Reverse of number means reverse the position of all digits of any number. For example reverse of 251 is 152
Here is source code of the C++ Program to Reverse a Number using while loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ Program to Reverse a Number using while loop */
#include<iostream>
using namespace std;
int main()
{
int no,rev=0,r,n;
cout<<"Enter any positive number :: ";
cin>>n;
no=n;
while(no>0)
{
r=no%10;
rev=rev*10+r;
no=no/10;
}
cout<<"\nReverse of a Number [ "<<n<<" ] is :: [ "<<rev<<" ] \n";
return 0;
}
Output : :
/* C++ Program to Reverse a Number using while loop */
Enter any positive number :: 123456
Reverse of a Number [ 123456 ] is :: [ 654321 ]
Process returned 0
Above is the source code for C++ Program to Reverse Number using while loop which is successfully compiled and run on Windows System.The Output of the program is shown above .
Reverse of number means reverse the position of all digits of any number. For example reverse of 251 is 152
Here is source code of the C++ Program to Reverse a Number using while loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
Output : :
Above is the source code for C++ Program to Reverse Number using while loop which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer