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 _________ attack is an attack on a computer system or network that causes a loss of service to users.
Svetlanka [38]

Answer: Denial of Service

Explanation:

the term is self-explanatory

7 0
3 years ago
Write a method public static ArrayList merge(ArrayList a, ArrayList b) that merges two array lists, alternating elements from bo
bogdanovich [222]
The answer would be 798 since all of them combined with the square root dividing it would give you that.
4 0
4 years ago
Which of the following is NOT a factor of identifying graphic design?
kolezko [41]

Answer:

i think it is a

Explanation:

sorry if it is wrong

4 0
3 years ago
Read 2 more answers
Advantages of e commerce
Sloan [31]

Answer:

A Larger Market

Customer Insights Through Tracking And Analytics

Fast Response To Consumer Trends And Market Demand

Lower Cost

More Opportunities To "Sell"

Personalized Messaging

Hope this helps!

4 0
4 years ago
Urgent. I will mark you brainliest. explain why cyber warfare is a real threat.​
stellarik [79]

Answer: Cyber warfare is a real threat since being able to hack another computer especially a countries computer with lots of info in their weaknesses can lead to their downfall. Since they can even possibly if their skilled enough hack their entire data base system and leak it to the public and that wouldn't be good for them not in a single possible way. That's the reason it's dangerous not only that but also because they can access their servers; which can let them access anything online from the whole country including banking information military info which can let them know which area there gonna go to next equipment there gonna bring and where they're gonna launch missiles, bombs, even nukes if they decide to launch one. And being able to hijack the computer that launches the nukes can make the hacker launch the nuke to a different place or launch the nuke on the country trying to launch the nuke.

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • HURRRYY After pasting the information on the left side of the comparison slide, Jamal notices the text box extends beyond the bo
    9·1 answer
  • (PLS HELP 99 POINTS) In a paragraph of no less than 125 words, explain the three aspects involved in gaining a true appreciation
    14·2 answers
  • A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some
    11·1 answer
  • Identify characteristics of top-down programming design. Choose all that apply.
    13·1 answer
  • When configuring services, what linux directory typically contains server configuration files?
    8·1 answer
  • List 7 basic internal component found in a computer tower?
    11·2 answers
  • Write a function to output an array of ints on a single line. Funtion Should take an array and an array length and return a void
    9·1 answer
  • What is a web server?​
    11·1 answer
  • Puede existir la tecnologia sin la ciencia y sin las tecnicas,explique si o no y fundamente el porque de su respuesta
    11·1 answer
  • Write an if-else statement for the following: If user_tickets is less than 5, assign num_tickets with 1. Else, assign num_ticket
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!