Hello all....I can't seem to figure out why the min value won't display correctly. Could someone please critique my program with out actually giving me the code.
I am so happy that I finally got my loop to work! I've been working on this all evening. It is a great satisfaction when you get something to actually work!
Here is what I came up with:
# include <iostream>
using std::cout; //program uses cout
using std::cin; //program uses cin
using std::endl; //program uses endl
//function main begins program execution
int main ( )
{
int a; //number of values in set inputed by user
int b; //number inputed by user
int c; //counter
int max=0; //highest vaule
int min=0; //lowest value
//processing phase
//get input from user
cout << "Enter the number of values in the set: "; //prompt for input
cin >> a; //read number from user
for ( c=1; c <= a; c++ ) {
cout << "Enter a number: "; //prompt for input
cin >> b; //read number from user
if (b <= max)
min = b;
if (b > max)
max = b;
}
cout << "The maximum value is: " << max << " ";
cout << "The minimum value is: " << min << " " <<endl;
return 0; //indicates that program ended successfully
} //end function main