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
Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the function in
storchak [24]

I wrote my code in python 3.8:

def max_magnitude(num1, num2):

   return num1 if abs(num1) > abs(num2) else num2

print(max_magnitude(-8,-2))

I hope this helps!

4 0
3 years ago
I will give brainyest
Trava [24]

Answer:

Power down your Chromebook by doing a hard reset.

Explanation:

The first thing to check for when your Chromebook won't turn on is a dead battery. Plug the unit in via AC charger and let it charge for at least 30 min to an hour and try turning it on again.

3 0
2 years ago
Read 2 more answers
Which internet explorer security feature restricts the browsing session information that can be tracked by external third-party
Anarel [89]

Tracking protection internet explorer security feature restricts the browsing session information that can be tracked by external third-party websites and applications

The internet can be a dangerous place, and it's important to take steps to protect your privacy. One way to do this is to enable tracking protection in your web browser.

Tracking protection is a security feature that restricts the information that can be tracked by external websites and applications. This means that your browsing session will be more private, and your data will be less likely to be collected and used without your consent.

To enable tracking protection in Internet Explorer, go to the Tools menu and select Internet Options. On the Privacy tab, click the Tracking Protection button. You can then choose to enable tracking protection for all websites, or only for certain websites that you trust.

Enabling tracking protection can help to keep your data safe and your privacy protected. So if you're concerned about online privacy, be sure to enable this feature in your web browser.

Learn more on internet explorer here:

brainly.com/question/28431103

#SPJ4

6 0
2 years ago
A storyboard is an example of an implementation tool.<br><br> A.<br> True<br><br> B.<br> False
Phantasy [73]
A True A storyboard is hardware installed directly onto the motherboard or using a <span>Peripheral device</span>
4 0
3 years ago
Read 2 more answers
Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
konstantin123 [22]

Answer:

User Interface

Explanation:

4 0
4 years ago
Other questions:
  • We never need to use a forward declaration when invoking a public subprogram. true or false?
    15·1 answer
  • Tom is the aerobics coordinator at a fitness center. He needs a more efficient way for his instructors to share information. Cla
    13·2 answers
  • Which type of disk uses primary partitions, extended partitions, and logical drives to organize data?
    9·1 answer
  • If a client is found _________ the NAP will attempt to make it _______. Group of answer choices A. non-compliant, compliant B. s
    13·2 answers
  • Assume that the int variables i and j have been declared, and that n has been declared and initialized.
    10·1 answer
  • Suppose you're currently completing an examination online. When you're finished, you click on Reset Exam. Why would you do this?
    8·1 answer
  • 3. When you right-click a linked spreadsheet object, what commands do you choose to activate the Excel features?
    7·2 answers
  • Write the WordSandwich method allSandwiches. This method creates and returns a new array of String objects as follows. Each elem
    13·1 answer
  • What is a circular network.​
    6·2 answers
  • Your network uses a network address of 137. 65. 0. 0 with a subnet mask of 255. 255. 0. 0. How many ip addresses are available t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!