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