Introduction
Control Statement
- Program to check whether the number is prime or not
- Program to check vowel or constant
- Program to check the largest number among three numbers
- Program to the sum of natural numbers
- Program to check leap year
- Program to find factorial of the number
- Program to find reverse of the number
- Program to Check Armstrong Number
- Program to find the sum of Natural Numbers using Recursion
Function
- Program to check prime number using Functions
- Program to convert Binary to Decimal Number
- Program to convert Decimal to Binary Number
- Program to convert Binary to Octal Number
- Program to convert Octal to Binary Number
- Program to find reverse of the sentence using Recursion
- Program to Shutdown and restart Computer
- Program to find the area of triangle
- Program to find LCM
Array
Pointer
OOPS
No Examples found for this topic - CodeHelpPro
Program to find reverse of the number
In this example, We will learnt to find reverse of any number using C++ programming language.
To understand this example, We must have knowledge on following topics
To do this program, First we will take integer from user.
Then, We will loop number checking condition that number is equal to zero.
We will find remainder dividing by 10 and set to remainder variable
And also We will multiply previous reverse variable by 10 and add that remainder that we just obtained above. On this way we will find the reverse of any number using c++ programming langauge.
Let’s look an example to make clear concepts.
#include <iostream>
using namespace std;
int main() {
int n, rev = 0, rem;
cout << "Enter an integer: ";
cin >> n;
while(n != 0) {
rem = n % 10;
rev = rev * 10 + rem;
n /= 10;
}
cout << "Reversed Number = " << rev;
return 0;
}
The output of above program is
Enter an integer: 123
Reverse Number = 321
Subscribe
Login
0 Comments
Inline Feedbacks
View all comments