Hey everyone I am having a really hard time trying to figure out what I am doing wrong in this program we are writing for class. The assignment is to use the for function to write a code that will first let the user choose how many iterations are run and second tell the user what the lowest number that was entered was. (The latter is where I am having some troubles.) I cannot seem to figure out how to get the program to store the previous lowest number for the life of me. I have tried everything I can think of. If anyone could help me out it would be much appreciated.
Here is my code:
Code:
#include <iostream>#include <iomanip>
using namespace std;
int main()
{
int MinNum = 0,
MaxNum = 1,
num2;
cout << "How many numbers would you like to enter? ";
cin >> MaxNum;
cout << endl;
for (int num = 1; num <= MaxNum; num++)
{
cout << "Enter a number: ";
cin >> num2;
if (!( num2 < MinNum))
MinNum = num2;
}
cout << endl;
cout << "Here is the lowest number you entered: " << MinNum << endl;
cout << endl;
system("pause");
return (0);
}