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
Andrews [41]
1 year ago
7

write a while loop that reads integers from input and calculates integer finalnum as follows: if the input is divisible by 5, ad

d the input divided by 5 to finalnum. otherwise, subtract the input multiplied by 5 from finalnum. the loop iterates until a negative integer is read. ex: if the input is 15 11 5 -3, then the output is: final number is -31 note: x % 5
Computers and Technology
1 answer:
ira [324]1 year ago
7 0

The while loop for the program that reads integers from input and calculates integer is illustrated thus:

#include <iostream>

using namespace std;

int main()

{

//declaring the variables

int userInput;

int outputVal;

outputVal = -19;

//take user input

cin >> userInput;

//take user input until negative input is given

while(userInput > 0)

{

 //if the input is divisible by 5, subtract the

 //input divided by 5 from outputVal

 if(userInput%5==0)

     outputVal -= userInput/5;  

 //if the input is not divisible by 5, add the

 //input multiplied by 5 from outputVal

  else

     outputVal += userInput*5;

   cin >> userInput; // take input

}

//print the output value

  cout << "Output value is " << outputVal << endl;

return 0;

<h3>What is a while loop?</h3>

A while loop is a control flow statement in most computer programming languages that allows code to be performed repeatedly based on a supplied Boolean condition. The while loop is similar to a looping if statement.

A "While" Loop is used to iterate over a certain block of code until a condition is met. If we wish to ask a user for a number between 1 and 10, we don't know how many times the user may enter a larger number, so we keep asking "while the number is not between 1 and 10."

Learn more about program on:

brainly.com/question/22654163

#SPJ1

You might be interested in
Select the correct answer. Which sentence best describe an effective management strategy? A. Conceal game-related clippings prio
andrew-mc [135]

Answer: I would say it is B

5 0
4 years ago
Read 2 more answers
What is predictive dialing?
Hunter-Best [27]
Answer: A

















Explanation:
3 0
3 years ago
A technician is testing a connector in a circuit with a voltmeter. With the power on in the circuit, the meter reads 12 volts wh
Gnesinka [82]

Since the technician is testing a connector in a circuit with a voltmeter and the others, one can say that this indicates that the connector is open.

<h3>What does an open connection implies?</h3>

Connecting to an open network is one that connote that one can opens their device to others using or on that same wireless network.

Note that Since the technician is testing a connector in a circuit with a voltmeter and the others, one can say that this indicates that the connector is open.

Learn more about open connection from

brainly.com/question/5338580

#SPJ1

7 0
2 years ago
Where would you click to change the<br><br>Screen Saver?​
ycow [4]

Answer:

Explanation:

Go to Settings > Personalization > Lock screen, and select Screen saver settings. In the Screen Saver Settings window, choose a screen saver from the drop-down list.

8 0
3 years ago
Read 2 more answers
Which of the following is NOT a Boolean Search term used to refine search engine results? A. AND B. With C. OR D. NOT
den301095 [7]
B. With. Width isn't a boolean comparative operator
7 0
4 years ago
Read 2 more answers
Other questions:
  • What is TCP/IP?
    13·1 answer
  • What does CSS stand for?
    8·2 answers
  • Isp servers are continually connected to a larger network, called a regional network, which, in turn, is connected to one of the
    6·1 answer
  • List several things that geographers can map using remotely sensed data
    5·1 answer
  • ________ reality is the addition of digital information directly into our reality, either to add more detail or to remove unwant
    7·1 answer
  • Regularly Tuning up a computer can assist keeping it running at Peak speed. True or False?
    12·1 answer
  • Do URLs identify the location of Web content?
    8·2 answers
  • Assuming x and y are variables of type float, the expression:
    6·1 answer
  • RAM that can be changed. True or False
    9·2 answers
  • The main work area of the computer is the
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!