Hi, I am trying to write a program that finds the minimun and maximum number in an input set of numbers. I am using a loop to update the set as the program reads the cin.
Example code:
min = max = -1
cout << "Enter termination value that will signal the end of data entry :"
cin >> term_val ;
cout << "Enter data values :";
while (data != term_val){
cin >> data
if (data<min) min = data;
else if (data>max) max = data;
n++;
}
Min and max are initially set to -1, and somewhere I have to set min and max to the first data value. This loop should update the min and max values after they are set to the first data value. Where in the code do I have to do this?
Thanks