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
If you are interested in a specific employer, but there are no job openings with the company, what steps should you take while y
GenaCL600 [577]

There are several ways you can inquire about a job or send an application even when the company isn’t hiring. One way that works best is to know the company. Don’t just like the company, have a particular demonstrated interest in that company. Understand their services and love their product. Another way is to enlist your network and connect with people on the inside who can give you tips on getting noticed. You can also send a letter of interest. In it, do not ask for a job. Explain yourself the value you will bring to their business. You can also show up on their doorstep and hand deliver a CV.

7 0
3 years ago
Read 2 more answers
I connected to an external hard drive to transfer some photos from my vacation. When I try to drag the photo, it bounces right b
Ilia_Sergeevich [38]
Your answer is D.

Hope this helps and if you could answer the question I just uploaded titled giving brainliest that would be great. Basically, what you have to do is research why the book titled the list of things that will not change and explain why it’s your favorite book based on the message it tells you! Go to my profile and go to questions.
7 0
3 years ago
Suppose you design a banking application. The class CheckingAccount already exists and implements interface Account. Another cla
Leona [35]

Answer:

Strategy

Explanation:

The strategic design pattern is defined as the behavioral design pattern that enables the selecting of a algorithm for the runtime. Here the code receives a run-time instructions regarding the family of the algorithms to be used.

In the context, the strategic pattern is used for the application for implementing OverdraftCheckingAccount class. And the main aspect of this strategic pattern  is the reusability of the code. It is behavioral pattern.

6 0
3 years ago
How to defrost chicken quarter in the microwave?
mash [69]
Use the automatic defrosting feature on your microwave
6 0
4 years ago
What is the purpose of anti-bullying laws
nasty-shy [4]
The purpose of anti-bullying laws is so that people aren’t getting bullied because when someone gets bullied it could cause them to become depressed and not happy on who they are
6 0
3 years ago
Read 2 more answers
Other questions:
  • What are some ways in which reading and writing have changed in our newly networked world
    10·1 answer
  • Which of the following resources is an example of a web-based application?
    15·1 answer
  • Which tag will you use if you want your web page to look the same as your source code?
    11·1 answer
  • Titus would like to make his products stand out a little more in his Excel spreadsheet. What actions would help to distinguish o
    15·1 answer
  • True or false? LearnSmart (the "smart flash card assignments") really gets your competitive spirit in gear by allowing you to se
    8·1 answer
  • Which input device can advanced computer users use instead of a mouse to perform tasks such as opening new windows and saving or
    15·1 answer
  • What are the procedures use in installing a sound card
    12·1 answer
  • Question No. 5:
    7·1 answer
  • Which manufacturing industry makes semiconductors that are used in a variety of systems?
    8·1 answer
  • Which of the following can be used to help find the error
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!