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 |
What Is Polymorphism in C++ ?
1 Answers IBS, Impetus, ITC Indian Tobacco Company, Motorola,
How to run C++ program in cmd
How does stack look in function calls? When does stack overflow? What can you do to remedy it?
Write a C++ Program to find Addition of Two Numbers.
CDPATH shell variable is in(c-shell)
Write a program that ask for user input from 5 to 9 then calculate the average
Discuss about iteration statements in C++ .
What are string library functions(syntax).
What is the difference between virtual functions and pure virtual functions?
dynamic scoping is
Write a program that can take input from 3 to 8 and calculate the average?
What is static variable and difference between(const char *p,char const *p,const char* const p).