
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Adam Number
Adam Number is a number whose square is reverse of the square of its reverse.
Concept Explained − For a number to be adam number, the square of number is reverse of the square of the reverse of the number. Let’s take an example,
12 is the number. Square of 12 is 144 and the reverse of 12 is 21. The square of reverse of 12 i.e. 21 is 441. 441 is the reverse of 144 which is the square of 12.
Algorithm to check if a number is adam number −
- Given the number xy, find the square of the number (xy)2.
- For xy reverse the digits of the number -> yx.
- Now, for the number yx, find the square of the number (xy)2.
- Reverse the digits of (xy)2 and evaluate with (yx)2.
- If both are equal, then the number is adam number.
Example
#include <iostream> using namespace std; int reverseDigits(int num) { int rev = 0; while (num > 0) { rev = rev * 10 + num % 10; num /= 10; } return rev; } int main() { int num = 31; cout<<num<<" is "; int rev = reverseDigits(num); if ( (num*num) == (reverseDigits(rev*rev)) ) cout << "Adam Number"; else cout << "not an Adam Number"; return 0; }
Output
31 is Adam Number
- Related Articles
- Adam Number in C++
- What is adam back?
- What is the starting number of Natural number and Whole number ?
- Complete the following sentences:Every real number is either… number or… number.
- Which of the following are true for an element?Atomic number = number of protons + number of electronsMass number = number of protons + number of neutronsAtomic mass = number of protons = number of neutronsAtomic number = number of protons = number of electrons(a) (i) and (ii)(b) (i) and (iii)(c) (ii) and (iii)(d) (ii) and (iv)
- Is every rational number a real number?
- Finding a number, when multiplied with input number yields input number in JavaScript
- Convert octal number to decimal number in Java
- Count number of factors of a number - JavaScript
- Reynolds Number
- Heptagonal number
- The isotopes of an element contain :(a) same number of neutrons but different number of protons(b) same number of neutrons but different number of electrons(c) different number of protons as well as different number of neutrons(d) different number of neutrons but same number of protons
- Which number is greater, the least $9$ digit number or the number which is $2$ more than the greatest $8$ digit number?
- Java program to convert decimal number to hexadecimal number
- C++ Program to Convert Octal Number to Binary Number

Advertisements