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 |
Name the operators that cannot be overloaded.
What are the fundamental features of an object-oriented language?
What is pass by value & reference.
In C++ what do you mean by Inheritance?
Describe the different styles of function prototypes in C++.
What is constant keyword in C++? Illustrate its various uses.
0 Answers Akamai Technologies, Infogain,
Explain about Searching and sorting algorithms with complexities
What are Agilent PRECOMPILERS?
What does it mean to declare a member function as virtual in C++?
Can we provide one default constructor for our class?
Without using third variable write a code to swap two numbers.
How does stack look in function calls? Write a recursive function call, how will the stack look like?