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 |
Explain what happens when an exception is thrown in C++.
Write a C++ Program to Display Number (Entered by the User).
Identify the errors in the following program. #include <iostream> using namespace std; void main() { int i=5; while(i) { switch(i) { default: case 4: case 5: break; case 1: continue; case 2: case 3: break; } i-; } }
Implement a 2D bit-matrix representing monochrome pixels which will have only OFF/ON values and will take on an average only one bit of memory for each stored bit. How to perform various operations on it?
Question on Copy constructor.
How do you write a function that can reverse a linked-list in C++?
Mention the default functions in C++, how would you detect that error has occurred inside the constructor and destructor.
How to convert integer to string in C++
What are Agilent PRECOMPILERS?
What is data abstraction? How is it implemented in C++?
Explain the operator overloading feature in C++ ?
What are pass by value and pass by reference?what is the disadvantage of pass by value?