- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Demlo number (Square of 11...1)” in C++?
Demlo numbers are palindromic numbers that are generated by the square of number of form 11..1 given that the number is less than 10 digits.
Let us first declare the string variables −
string demNum = "1111"; string square = "";
Now, we loop till the length of the demNum string. Inside the loop we convert the index value i to string and append it to square variable.
for(int i=1 ;i<=demNum.length();i++){ square += char(i+'0'); }
In the second loop we loop in reverse starting from the length of demNum string. Inside the loop we convert the index value i to string and append it to square variable.
for (int i = demNum.length() - 1; i >= 1; i--) square += char(i + '0');
Example
Let us see the following implementation to get a better understanding of demlo numbers −
#include <iostream> using namespace std; int main(){ string demNum = "1111"; string square = ""; for(int i=1 ;i</=demNum.length();i++){ square += char(i+'0'); } for (int i = demNum.length() - 1; i >= 1; i--) square += char(i + '0'); cout << square; return 0; }
Output
The above code will produce the following output −
1234321
- Related Articles
- Demlo number, Square of 11...1 in C++ Program
- The Property Satisfies the condition for addition of whole number (78+1)+11=78+(1+11) is ___________
- Program to find number of square submatrices with 1 in python
- Minimum number of Square Free Divisors in C++
- Find the square of each number. 1) 14 2) 0.17
- Fill in the boxes: (a) ( square-frac{5}{8}=frac{1}{4} )(b) ( square-frac{1}{5}=frac{1}{2} )(c) ( frac{1}{2}-square=frac{1}{6} )
- Fill in the blanks:(a) ( 369 div square=369 )(b) ( (-75) div square=-1 )(c) ( (-206) div square=1 )(d) ( -87 div square=87 )(e) ( square div -1=-87 )(f) ( square div 48=-1 )(g) ( 20 div square=-2 )(h) ( square div(4)=-3 )
- Check if a number is perfect square without finding square root in C++
- Find the square root of 11 correct to five decimal places.
- The number of pairs of two digit square numbers, the sum or difference of which are also square numbers is(1) 0(2) 1(3) 2(4) 3
- Write true (T) or false (F) for the following statements.(i) The number of digits in a square number is even.(ii) The square of a prime number is prime.(iii) The sum of two square numbers is a square number.(iv) The difference of two square numbers is a square number.(v) The product of two square numbers is a square number.(vi) No square number is negative.(vii) There is not square number between 50 and 60.(viii) There are fourteen square numbers upto 200.
- The atomic number of sodium is 11 and its mass number is 23. It has(a) 11 neutrons and 12 protons (b) 12 protons and 11 electrons(c) 11 electrons and 12 neutrons (d) 12 electrons and 11 neutrons.
- Write 2 different irrational number lying between $frac{3}{7}$&$ frac{1}{11}$.
- Program to find N-th term of series 1, 2, 11, 12, 21… in C++
- N-th term in the series 1, 11, 55, 239, 991,…in C++

Advertisements