Smallest integer

I am attempting to find the smallest integer from an undetermined amount of integers... the logic of my code does not work (it does not know which integer is smaller) and for some reason it is not looping the for statement... any help would be appreciated...

#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
int smallestnumber;
int nextnumber;
int total;

cout << "How many numbers will you be comparing? ";
cin >> total;

cout << "Please enter first integer: ";
cin >> smallestnumber;

for (int counter = 1; counter <= total; ++counter );
{

cout << "Please enter next integer: ";
cin >> nextnumber;

if (nextnumber <= smallestnumber);
(nextnumber = smallestnumber);

}

cout << "Smallest Number is: " << smallestnumber << endl;

system("pause");

return 0;
}
1
2
if (nextnumber <= smallestnumber) // there was an ';' here
nextnumber = smallestnumber;
thank you, that fixed the logic portion of it... however it is still only allowing two integers to be entered no matter how many is entered into the 'total'
Remove the semi colon at the end of the for loop line.
Your for loop also has a semicolon after it you don't want.

I think you also probably want to switch the order of assignment; smallestnumber should be being set equal to nextnumber, not the other way around.
oh wow... thank you... i feel stupid now...
Topic archived. No new replies allowed.