Question

how to solve this on c++?

Write a program that reads a five digits integer, then swaps the unit position digit with the ten thousandth position digit, also swap the tenth position digit with the thousandth position digit. Print the new number For example if the number is 37846 then the new number is 64873. Sample input / output: nter a five digits integer The new form of the number 37846 is 64873

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;
int main(){
   int number,rem,reverseNumber=0,tempNumber;
   cout << "Enter any number : ";
   cin >> number;
   //tempNumber is used to stored the number
   tempNumber = number;
   //runs until number > 0
   while(number>0){
       rem = number%10;
       number=number/10;
       reverseNumber = reverseNumber*10+rem;
   }
   cout << "The new form of the " << tempNumber << " is : " << reverseNumber;
   return 0;
}

output:

Terminal Enter any number 36589 The new form of the 36589 is: 98563 (program exited with code: 0) Press return to continue

Add a comment
Know the answer?
Add Answer to:
how to solve this on c++? Write a program that reads a five digits integer, then...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python only 15. Write a program that reads a five-digit positive integer and breaks it...

    in python only 15. Write a program that reads a five-digit positive integer and breaks it into a sequence of individual digits. For example, the input 16384 is displayed as 16384

  • Write a program that reads in an integer, and breaks it into a sequence of individual...

    Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate line. For example, the input 16384 is displayed as 1 6 3 8 4 You may assume that the input has no more than five digits and is not negative. - need Algorithms, Java Program and screenshot, please.

  • Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from...

    Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 42339, the program should print “4 2 3 3 9.” (Hint: The number input is five digits long, dividing it by 10000 gives the leftmost digit. digit1 = number / 10000 ) b. determines...

  • ***USING PYTHON***Write a program that reads a five-digit positive integer and breaks it into a sequence...

    ***USING PYTHON***Write a program that reads a five-digit positive integer and breaks it into a sequence of individual digits. for example , thin put 16384 is displayed as: 1 6 3 8 4

  • Write an application in java that reads in a five-digit integer and determines whether it is...

    Write an application in java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Tips: 1. Determine the number of digits in the value input by the user , i.e. prompt the user to enter the number of digits of the number. Use a while loop to determine whether the user input contains the proper...

  • Using Dev C++, write a program to solve the problem as stated below. Write a program...

    Using Dev C++, write a program to solve the problem as stated below. Write a program will input a single integer value (all input will be exactly 8 digits long) and will store pairs of digits as individual integer values. The program will display the five 2-digit numbers as well as the average of these, each on their own line. Use a switch statement to print out Grade: and then either A (>=90), B ([80..89]), C ([70..79]), D ([60..69]) or...

  • Program : Write a complete C++ program that Input: Read a positive integer from the keyboard...

    Program : Write a complete C++ program that Input: Read a positive integer from the keyboard (user) with proper prompt text and save it to a variable. The integer have up to five digits. Processing: From the right most digit, extract every digit from the input integer using modular operator %then save the digit to a separate variable. Remove the right most digit from the integer using integer division operator /. Repeat above two steps till all digits have been...

  • write it in C++ please Exercise # 1 : The 10 digits are spelled out respectively...

    write it in C++ please Exercise # 1 : The 10 digits are spelled out respectively as follows: "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", and "Nine". Write a program that prompts the user to enter a one digit positive integer and prints the number of characters required to spell out the integer. For example, if the integer is 7 then it is spelled "Seven" which requires 5 characters. Sample input/ output: Enter a one digit number: 8...

  • C++ please Problem 3: Write a C++ program that prompts the user to enter an integer...

    C++ please Problem 3: Write a C++ program that prompts the user to enter an integer of any length (but not more than 8- digits), the program then extracts and prints each digit in its respective column. For example, in the integer 436, 4 should be printed in the 4th column, 3 in the 3rd and 6 in the 6th column. Hint: you can use setw to solve this problem. Sample Input/Output Enter an integer of any length. 9836472 ...Printing...

  • Programming language is C++. 9. Write a program that reads digits and composes them into integers....

    Programming language is C++. 9. Write a program that reads digits and composes them into integers. For example, 123 is read as the characters 1, 2, and 3. The program should output 123 is 1 hundred and 2 tens and 3 ones. The number should be output as an int value Handle numbers with one, two, three, or four digits. Hint: To get the integer value 5 from the character '5' subtract '0' that is, '5'-'0'

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT