Hi guys,
Quick question, I was trying out to determine the second smallest number of 10 random entered numbers, this is what I got:
#include <stdafx.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main(void)
{
int s=0,x=0,y=0;
cout<< "Input ten random numbers with cin and determine the second smallest number"<< endl;
for(int i=0;i<10;i++)
{
cin>> x;cin.get();
if (x<s)
{
s=x;
if (s<y)
{
y=s;
}
}
}
cout<< "The second smallest number is: " << y << endl;
cin.get();
return (0);
}
Problem is that s equals zero, and even if I change that, I'm not getting the result I wanted :)
Can any of you guys give me some advice, this is just something that I'm trying out for myself and is not evening school related :!:
Thanks,
JoBe