Write a C++ Program to Reverse a Number using while loop.
Answer Posted / hr
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 |
Post New Answer View All Answers
Write some differences between an external iterator and an internal iterator?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
Explain the virtual inheritance in c++.
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
Explain deep copy and a shallow copy?
Keyword mean in declaration?
Why we use classes in oop?
Can comments be longer than one line?
What is runtime polymorphism in c++?
How would you use qsort() function to sort an array of structures?
what is VOID?
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
What is const pointer and const reference?
What are multiple inheritances (virtual inheritance)?
Are c and c++ similar?