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
4
madam [21]

Answer:

its the basic link

Explanation:

6 0
3 years ago
Read 2 more answers
This procedure protects against the loss of data
Arte-miy333 [17]
Data Backup and Recovery is the procedure that protects against the loss of data. It is to protect the crucial data against losing in events like physical disaster, database corruption, hardware failures, and other incident that can cause the data to lose.
6 0
3 years ago
What do you mean by data sequencing​
Shalnov [3]

Answer:

Data sequencing is the sorting of data for inclusion in a report or for display on a computer screen.

Explanation:

8 0
3 years ago
Which Internet resource can you use to publicly describe an adventure trip you recently made?
olasank [31]
If your planning on going social Facebook is the way to go ! But for most people you may decide to post anonymously so ! Search "Anonymous Posts" on google and their should be many websites you can anonymously tell you trips and embarrassing experiences safely on :)
8 0
3 years ago
_______________ is the term for the convergence of real-time and non-real-time communications services such as telephony, instan
Anna007 [38]

Answer:

Unified communications

Explanation:

Unified communications is the term for the convergence of real-time and non-real-time communications services such as telephony, instant messaging, video conferencing, speech recognition, voice mail, and email into a single interface.

8 0
3 years ago
Other questions:
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • A(n)________________ is something that goes into a system a resource such as time,money,communication,etc
    10·1 answer
  • Write a full class definition for a class named Averager, and containing the following members:______An data member named sum of
    6·2 answers
  • Public static String doSomething(String s) { final String BLANK = " "; //BLANK contains a single space String str = ""; //empty
    6·1 answer
  • Which diagram is used as a popular technique for investigating causes and effects? 1. Cause and effect 2. Fishbone/lshikawa 3. R
    13·1 answer
  • What is the role of the memory in a computer ​
    11·1 answer
  • If an occupation is projected to decline by 7% over the next 10 years, how would you rate the job outlook? (6 points)
    14·1 answer
  • What is a word processing program? Give examples of word processing programs.
    10·1 answer
  • 11 Select the correct answer. Which external element groups items in a design?
    9·1 answer
  • when I turn on my pc using a graphics card, it does give video, and everything is normal, but when I try to turn on my pc with t
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!