64 669
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #15123 in C++ for Zac

Question #15123
Write a C++ program with a while loop structure. This program will reads a list of
non-zero integers from the standard input device, and displays the largest and the
smallest number, and the difference between them. The program will end when a 0
value is read. This final value 0 will not participate in the required calculation.
Develop a Defining Diagram (i.e. an IPO Diagram) before writing the program.
Expert's answer
#include<iostream>
using namespace std;

int i=0, max, min, a=1;

void main(){
while (a!=0){
& cout<<"enter an integer or 0 to stop: ";
& cin>>a;
& if (a!=0){
& if (i==0) { max=a; min=a; }
& if (a>max) max=a;
& if (min>a) min=a;
& i++;
& }
}
cout<<"The minimum entered value: "<<min<<"\n";
cout<<"The maximum entered value: "<<max<<"\n";
cout<<"The difference: "<<max-min<<"\n";
system("PAUSE");
}





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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions