@rogster001: Thanks
@OP:
1)
> intnumber[2];
> cin >> number[0];
Why would you use an array under such circunstances? Considering the input is supposed to be solely 1 number, you'd be better off doing it this way:
int number;
cin>>number;
2)
>if(number[0] == 1)
I don't understand this piece of code. The program is supposed to close if the user inserts a number other than 1?
3)
Your loop itself is kinda messy. You'd be better off doing something like this:
Code:
//why from 0 to 9(Or from 1 to 10)? i equals to the number of tries and should beggin with the 1st try, which is i=1 or i = 0 + 1
for (int i = 0; i < 10; i++)
{
//Logicly the number of attempts goes from the lowest to the highest, ain't that right?
//eg. 1st attempt, then 2nd attempt, etc etc.
switch (i)
{
case 0:
std::cout << "This is your 1st attempt\n";
break;
case 1:
std::cout << "This is your 2nd attempt\n";
break;
case 2:
std::cout << "This is your 3rd attempt\n";
break;
default:
std::cout << "This is your " << i + 1 <<"th attempt\n";
break;
}
//Here you get to input a number everytime the loop goes
int number;
std::cout << "Enter a number: ";
std::cin >> number;
std::cin.ignore();
//The following if conditions check whether the 10 attempts have been reached or if the user inserted the correct number (2)
if (number == 2)
{
std::cout<<"You won!";
break;
}
if (i == 9)
{
std::cout<<"You lose";
break;
}
}