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
kupik [55]
3 years ago
6

#11. Write a program that prompts the user to input a four-digit positive integer. The program then outputs the digits of the nu

mber, one digit per line. For example, if the input is 3245, the output is:
Computers and Technology
1 answer:
JulsSmile [24]3 years ago
7 0

Answer:

<em>C++</em>

/////////////////////////////////////////////////////////////////////////////////////

#include <iostream>

using namespace std;

int main() {

   int number;

   cout<<"Enter four digit positive integer: ";

   cin>>number;

   ///////////////////////////////////////////////

   int divisor = 1000;

   int digit;

   

   if ((number > 999) && (number < 9999)) {

       for (int i=0; i<3; i++) {

           digit = number/divisor;

           number = number%divisor;

           divisor = divisor/10;

           cout<<digit<<endl;

       }

       cout<<number;

   }

   else {

       cout<<"Invalid range!";

   }

   ///////////////////////////////////////////////

   return 0;

}

Explanation:

To accomplish the task, we need to use the divide and modulo operators.

To get each digit, we need to divide the variable number by the divisor (which is initialized to 1000).

We also need to reset the number variable to one less digit from the right. We can do this by number modulo divisor, which is assigned back to the number variable.

Finally we need to lower the divisor by 10 each time in the loop, to keep it in accordance with the above two operations.

You might be interested in
To add or remove space before or after a paragraph, users should select.
anzhelika [568]

To add or remove space before or after a paragraph, users should select the Line and Paragraph Spacing icon.

6 0
3 years ago
Read 2 more answers
What occurs in a steam engine?
VARVARA [1.3K]
Fist one correct.
second wrong because not all heat is used for work, some of it lost to other.
third wrong because fuel burn inside is called combustion engine
 <span />
7 0
3 years ago
Read 2 more answers
What are the technical details about each hardware component called?
RideAnS [48]
Specifications are the technical details about each hardware component
8 0
3 years ago
(Type the correct answer in the box.)
mihalych1998 [28]

1. If in MS Access, Click on Query design, select the required Table.

 In Field select required field, in this case Select [Name of Plants]. Click on Order and set it as Ascending / Descending.

2. If you want to write a Query that it will look like this

SELECT MedicinalPlants.Name of the plantsFROM MedicinalPlantsORDER BY MedicinalPlants.Name of the Plants;

Read more on Brainly.com - brainly.com/question/3433328#readmore

4 0
3 years ago
Read 2 more answers
If you have an if/else if/else code sequence with 4 blocks, what is the minimal number of input values that you should use to te
yawa3891 [41]

Answer:

4 is the correct answer for the above question.

Explanation:

  • If the if-else sequence has 4 blocks then it will be designed like if, else-if, else-if and then else which made 4 blocks which are as follows:-
  1. The first block is an if block.
  2. Then the second block is an else-if block.
  3. The third block is also else-if block and
  4. The fourth block else blocks.
  • So there is a need of 4 value (one value for each case) to test the application which is defined in the above scenario.
  • It is because when the first if statement is false then the first else-if statement is executed and when the first else statement is false then the second else-if statement is executed and when it is false then the else statement will executed.
7 0
3 years ago
Other questions:
  • If you are installing separate anti-virus and anti-spyware programs, which should you install first
    7·1 answer
  • 5. How is shutter speed generally measured? What do the measurements mean?
    7·2 answers
  • Describe Ms word environment.​
    14·1 answer
  • How will you create an email id
    11·1 answer
  • Which is a correctly formatted Python tuple?
    9·1 answer
  • Computer is created by aliens?!
    14·1 answer
  • Dang was accepted to a biology program with a rigorous schedule and a high tuition, but good professors. What would be a benefit
    10·2 answers
  • 次のうち、ビジネスレターに適したフォントとポイントサイズの選択はどれですか?<br> 私を助けてください!私はあなたを最高にブランコにします!
    12·2 answers
  • A company has critical systems that are hosted on an end-of-life OS. To maintain operations and mitigate potential vulnerabiliti
    14·1 answer
  • Difference between sorting and filtering​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!