1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
artcher [175]
3 years ago
6

Write a program in C++ that will ask the user to enter a five-digit integer. The program will detect if the number entered is a

palindrome or not. Make sure the user enters a five-digit integer, not five single digit integers.
The program must have validation; that is, it must ensure the value entered is a five-digit integer (i.e. an integer between 10000 and 99999.
Computers and Technology
1 answer:
vagabundo [1.1K]3 years ago
5 0

Answer:

//here is code in C++.

#include <bits/stdc++.h>

using namespace std;

int main()

{

// variables

int num,num_copy;

int new_num=0;

cout<<"enter a five digit number: ";

// read number from user

cin>>num;

// check input is a 5 digit number or not

while(num<10000||num>99999)

{

   cout<<"Wrong input!!"<<endl;

   cout<<"enter a five digit number only: ";

   // if input is wrong it will again ask user to enter 5 digit number

   cin>>num;

}

// make a copy of input number

num_copy=num;

//reverse the digits of input and make a new 5 digit number

while(num>0)

{

   int r=num%10;

   new_num=new_num*10+r;

   num=num/10;    

}

// check if both number are same or not

// is same then print palindrome else not palindrome

if(num_copy==new_num)

cout<<"number is palindrome"<<endl;

else

cout<<"number is not palindrome"<<endl;

return 0;

}

Explanation:

Read a five digits number from user.If input is not a five digits number then it will ask again to enter a five digit number until user enter the correct input. Then it make a copy of the input number.It will make a new five digit number by  reversing the digits of input number.Then it will match both the number, if they  match then it will print "palindrome" else "not palindrome".

<u>Output:</u>

enter a five digit number: 123                                                                                             Wrong input!!                                                                                                              enter a five digit number only: 222221                                                                                     Wrong input!!                                                                                                              enter a five digit number only: 23432                                                                                      number is palindrome

enter a five digit number: 12345                                                                                           number is not palindrome

You might be interested in
A ____ is text and graphics that print at the bottom of every page.
oksano4ka [1.4K]
Foot note, or footer.
6 0
4 years ago
I need HELP ASAP! 30 POINTS to the RIGHT answer.
Travka [436]
I would say go with
D. winzip
5 0
4 years ago
Read 2 more answers
In spreadsheets, a cell reference is also referred to as which of the following? A. active cell B. axis C. cell address D. entry
nignag [31]
Generally its referring to the cells location, so C.
4 0
3 years ago
What is a blog . explain with example clearly .​
const2013 [10]

Answer:

A blog (a truncation of "weblog") is a discussion or informational website published on the World Wide Web consisting of discrete, often informal diary-style text entries (posts). Posts are typically displayed in reverse chronological order, so that the most recent post appears first, at the top of the web page.

Explanation:

3 0
3 years ago
Artie believes that all Asian people are more intelligent than other people. Artie is engaging in?
Luden [163]
Artie is Stereotyping
5 0
3 years ago
Read 2 more answers
Other questions:
  • Microsoft Surface can do all of the following except ______.
    12·2 answers
  • What is intergrated circuit ic​
    10·1 answer
  • What is the name of Louis and Auguste Lumiere's invention that incorporated a camera, a printer, and a project all in one machin
    8·1 answer
  • hi i'm bored so.... free point and if you have any Netflix shows that are good do tell also i'm going to pick one person to give
    7·2 answers
  • Which statement describing an operating system's Search feature is true?
    5·1 answer
  • How does is make you feel when you're kind to others? What are some opportunities in your life to be more kind to your friends a
    9·1 answer
  • Identfy two duties of the governer stationed at mombasa under portugues rule?​
    8·1 answer
  • Indicate whether the following statements are true or false:
    14·2 answers
  • Pls help due tonight<br>Will give brainiest
    13·2 answers
  • 8. Software ____ are individual programs that can be purchased, installed, and run separately, but extract data from the common
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!