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
PowerPoint provides a wide variety of predefined shapes that can add visual insert to a slide true or false
lozanna [386]
PowerPoint provides a wide variety of shapes for visual inserts this is true
6 0
3 years ago
Read 2 more answers
How many questions must you answer in Brainly to be able to message people?
spayn [35]

Answer:

you need to answer 1k questions

7 0
2 years ago
Read 2 more answers
How many bits are used to direct traffic to specific services running on a networked computer?
Mars2501 [29]

Answer:

The correct answer is 16 bit.

Explanation:  

The main role of the transport layer provided the communication channel of the process which are running in a different host. When the information flows there is always traffic that is arisen but the transport layer aimed is that process will go at the correct node and received at the proper destination. The 16-bit number specifies that the process or node is running in the networked traffic.

3 0
3 years ago
What is the purpose of an arraignment?
IgorC [24]

Answer:

At an arraignment, the court officially illuminates a litigant regarding charges contained in a prosecution or data, gives the respondent a duplicate of the charging instrument, and takes the litigant's response to those charges as a request.

Explanation:

5 0
3 years ago
Read 2 more answers
Please help! first one to answer correctly gets brainliest and thanked
jonny [76]
It’s either presentation Because the software is used to create a sequence of texting, graphics and often audio and video to accompany a speech or a public presentation, or letter
6 0
3 years ago
Other questions:
  • The cost of large ground based telescopes has remained the same since the 1800's costing the equivalent of about a billion dolla
    9·1 answer
  • Angle, oblique, regular, demi, roman, heavy, extra bold, expanded, and compressed are ___________ . Select one: A. type styles B
    10·1 answer
  • Which is most likely a presentation file?
    8·1 answer
  • 2
    11·1 answer
  • Xavier would like to change the sort options for his contacts. In which tab will he find the Arrangement command group?
    6·1 answer
  • 8.Which of the following IC was used in third generation of computers?Immersive Reader
    13·1 answer
  • You upgrade a graphics workstation with a HyperThreading-enabled CPU core. You expect the programs on the desktop to run much fa
    12·1 answer
  • Which of the following expressions in Java is equal to 4?
    11·1 answer
  • Type the correct answer in the box
    13·1 answer
  • A while loop is frequently used to ______________ data.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!