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
All digital images are made up from varying rectangles of color, called _____________.
Dmitry_Shevchenko [17]
<span>A Pixel (a word invented from "picture element") is the basic unit of programmable color on a computer display or in a computer image.</span>
4 0
3 years ago
Read 2 more answers
Which magazine can help public determine best technology to buy
Dennis_Churaev [7]
Consumer report would help determine the best technology to buy.
4 0
3 years ago
Which domain indicates that a website is sponsored by a university or college?
d1i1m1o1n [39]

There are two domains that are commonly associated with sites that owned by a university or college: .edu and .ac.

In the case of .edu, <u>it is only available for United States higher education institutions or higher education institutions outside U.S that are affiliated with the United States since 2001.</u>

For non-U.S colleges and universities, they will commonly <u>use .ac as a second-level domain before putting in their country domain as the top-level domain.</u> Examples of this would be .ac.uk and .ac.jp.  


8 0
3 years ago
What is are example of an engineered item?
zysi [14]
Trains, Cars, Boats, Airplanes
3 0
3 years ago
HELP PLEASE True or False? A human is needed to create algorithms that computers use
AveGali [126]
I guess true but also false if technology develops more to write it’s own algorithms.
3 0
3 years ago
Read 2 more answers
Other questions:
  • "the most common way to access the internet is through ________."
    5·1 answer
  • A computer company has $3840000 in research and development costs. Before accounting for these costs, the net income of the comp
    5·1 answer
  • You want to average the numbers in the range b1:b30. you have named this range of cells data and wish to use this range name in
    9·1 answer
  • In what year was the 1st zelda game released
    5·2 answers
  • You
    15·2 answers
  • Consider the classes below: public class TestA { public static void main(String[] args) { int x = 2; int y = 20 int counter = 0;
    8·1 answer
  • How do i convert videos on the computer
    10·1 answer
  • Which note taking strategy has you divide a page into 3 sections for your notes, key points, and summary?
    11·1 answer
  • An object's state is defined by the object's
    6·1 answer
  • How to create a trace table
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!