I have a program where the user inputs a line of numbers, and the two highest ones are displayed. It works fine, until negative values are entered at which point it shows 0 as the result. Can someone help?
Code:
#include <iostream>
using namespace std;
int main( ) {
int num = 0;
int highest = 0;
int secondhighest = 0;
int input = 0;
cout << "How many numbers? "; 
	 cin >> num; 
	 cin >> input; 
	 int input2 = input;
//	 highest = input;
	// secondhighest = input;
for(int track = 0; track < num; track++) 
{       
        if(track == 1) {
                 input = input2;
                 }
else {                 
cin >> input;
}




if (input > highest) {		  
secondhighest = highest;
highest = input;	
}
else if (input > secondhighest) {
secondhighest = input;
}
}		
cout << endl;
cout << "Highest: " << highest << endl; 
	
cout << "Second: " << secondhighest; 	
}