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
Hatshy [7]
2 years ago
8

Read a 4 character number. Output the result in in the following format, Input 9873, Output 3 *** 7 ******* 8 ******** 9 *******

** If one of the numbers is not a digit, then put a ? mark Input = 98a3, Output 3 *** a ? 8 ******** 9 ********* Prompt the user before the input with, cout<<"Create a histogram chart."<
Engineering
1 answer:
Rus_ich [418]2 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int main()

{

 char numbers[4];

 

 cout<<"Create a histogram chart."<<endl;

 cout<<"Enter your number as 4 characters: ";

 

 cin >> numbers;

 

 for (int i=3; i>=0; i--) {

   int ascii_value = numbers[i];

   int number = numbers[i] - '0';

   

   if (ascii_value >=48 && ascii_value <=57) {

       cout << number;

       

       for (int j=number-1; j>=0; j--) {

           cout << "*";    

       }

   }

   else {

       cout << "a ?";    

   }

   

   cout << endl;

 }

}



Explanation:

Declare a character array with length 4,

Ask user to enter values,

Create a nested for loop; first loop <u>holds the values and their ASCII values for each character</u>,

<u>Check the ASCII values</u> for each character, if they are <u>between 48 and 57</u>, that means they are numbers. In this case, print the number and go to the inner loop and print the stars accordingly,

If ASCII values are not in the range, print a ?,

Go to the new line after each character

You might be interested in
How can feeding plant crops to animals be considered an efficient use of those crops?
stira [4]

Answer:

Most of Our Grain is Being Consumed by Animals, Not Humans. How the Planting of Crops Used to Feed Livestock is Contributing to Habitat Destruction.

Explanation:

The major feed grains are corn, sorghum, barley, and oats.

7 0
2 years ago
Ventajas motor avion
Sauron [17]

Answer:

Explanation:

Usar motores eléctricos en aviones ofrece numerosas ventajas reales. A diferencia de los motores de combustión interna los motores eléctricos no necesitan aire para funcionar, lo que significa que pueden mantener toda su capacidad y potencia incluso a altitudes elevadas donde el aire es más tenue.

4 0
2 years ago
You are considering purchasing a compact washing machine, and you have the following information: The Energy Guide claims an est
RSB [31]

Answer: $15.34

Explanation: see image below

8 0
2 years ago
Are ocean currents always cold
swat32

Answer:

The surface ocean currents have a strong effect on Earth's climate. ... However, these areas do not constantly get warmer and warmer, because the ocean currents and winds transport the heat from the lower latitudes near the equator to higher latitudes near the poles.

8 0
2 years ago
Describe how you would control employee exposure to excessive noise in a mining environment
Alexandra [31]

Answer:

1. Buy Quiet – select and purchase low-noise tools and machinery

2. Maintain tools and equipment routinely (such 3. as lubricate gears)

3. Reduce vibration where possible

4. Isolate the noise source in an insulated room or enclosure

5. Place a barrier between the noise source and the employee

6. Isolate the employee from the source in a room or booth (such as sound wall or window

Explanation:

Hope my answer will help u.

7 0
1 year ago
Other questions:
  • Water flows down a rectangular channel that is 1.2 m wide and 1 m deep. The flow rate is 0.95 m/s. Estimate the Froude number of
    15·1 answer
  • Air,in a piston cylinder assembly, is initially at 300 K and 200 kPa.It is then heated at constant pressure to 600 K. Determine
    12·2 answers
  • A torsional pendulum consists of a 5 kg uniform disk with a diameter of 50 cm attached at its center to a rod 1.5 m in length. T
    13·1 answer
  • Two metallic terminals protrude from a device. The terminal on the left is the positive reference for a voltage called vx (the o
    9·2 answers
  • Determine the design angle ϕ (0∘≤ϕ≤90 ∘) between struts AB and AC so that the 400 lb horizontal force has a component of 600 lb
    10·1 answer
  • Water enters an ice machine at 55°F and leaves as ice at 25°F. If the COP of the ice machine is 2.45 during this operation, dete
    7·1 answer
  • Tech A says that LED brake lights illuminate faster than incandescent bulbs. Tech B says that LED brake lights have
    13·1 answer
  • Explain what the engineering team should advise in the following scenario.
    7·1 answer
  • For heat transfer purposes, a standing man can be mod-eled as a 30-cm-diameter, 170-cm-long vertical cylinderwith both the top a
    11·1 answer
  • A system of organization, people activities, informations, and resources involved in supplying a productor or service to a custo
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!