76 361
Assignments Done
Successfully Done
In May 2019

Answer to Question #48217 in C++ for Eunsu Kim

Question #48217
Reads just one double each time around by while loop. define two variables to keep track of which is the smallest and which is the largest value you have seen so far. Each time through the loop write out the value entered. If it's the smallest so far, write the "the smallest so far" after the number. If it is the largest so far, write "the largest so far" after the number.
Expert's answer
#include <iostream>

using namespace std;

int main() {
boolfirst = true;

while(1) {
cout<< "Input number: ";
cin>> current;
if(first) {
max= current;
min= current;
first= false;
cout<< "Your number is " << current;
if(current >= max) {
max= current;
cout<< " the largest so far";
if(current <= min) {
min= current;
cout<< " the smallest so far";
cout<< endl;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions