Write a C++ Program to Reverse a Number using while loop.
Solution:
/* 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<<"
Reverse of a Number [ "<<n<<" ] is :: [ "<<rev<<" ]
";
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
| Is This Answer Correct ? | 0 Yes | 0 No |
Write a C++ Program to find Square Root of a number using sqrt() function.
what is a pragma in C++?
What is the difference between creating an object, using 'new' and using 'malloc'?
Without using third variable write a code to swap two numbers.
write a program To generate the Fibonacci Series.
How to reverse a string in C++
What is meant by exit controlled loop?
what is the difference between a pointer and a reference?
0 Answers Amazon, Blue Star, C DAC,
Identify the error in the following program. include<iostream> using namespace std; void main() { int num[]={1,2,3,4,5,6}; num[1]==[1]num ? cout<<"Success" : cout<<"Error"; }
How to invoke a C function using a C++ program?
What do you by Function Overloading in C++?
0 Answers Akamai Technologies, Infogain,
What is RTTI and why do you need it?