Hi, I'm new to C++, and I made this program that makes either 1, or 2 pop up. And for 1, a text field is suppost to pop up to show you won, and if 2 pops up, it's suppost to say you lose. I got everything down (The unmber generator and stuff) But I'm having trouble with the IF and ELSE statement... The IF statement works fine, but my ELSE statement doesn't show up.... Here is the code....
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
system("CLS");
cin.clear();
srand((unsigned)time(0));
int random_integer;
for(int index=0; index<1; index++){
random_integer = (rand()%2)+1;
cout << random_integer << endl;
if(index=1)
{
cout << "You won!" << endl << endl;
}else{
cout << "You lose...."<< endl << endl;
}
system("PAUSE");
return 0;
}
}
Please if anyone can point out what is wrong, please tell me, thx :D