#include < iostream>
usingnamespace std;
int main()
{
int s = 0;
char letter;
char b,i,r,d;
for ( int z = 0; z < 5; z = z + 1 )
{
cout << "enter a letter? ";
cin >> letter;
if ( letter == b || i || r || d )
{
cout << "correct" << endl;
s = s + 1;
}
else
cout << " wrong try agian you still have: " << z << "tries\n";
}
if ( s <= 4 )
cout << "you win" << endl;
else
cout << " you lose" << endl;
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int s = 0;
char letter;
char b,i,r,d;
for ( int z = 0; z < 5; z = z + 1 )
{
cout << "enter a letter? ";
cin >> letter;
if ( letter == b || i || r || d )
{
cout << "correct" << endl;
s = s + 1;
}
else
cout << " wrong try again you still have: " << z << "tries\n";
}
if ( s <= 4 )
cout << "you win" << endl;
else
cout << " you lose" << endl;
return 0;
}
The problem was there you put < iostream> so you shouldn't of had that space before iostream. Also when you make your first for loop, instead of z = z + 1 do for ( int z = 0; z < 5; ++z ) And I cant stress this enough, ++z IS NOT I REPEAT IS NOT the same as z++. j = ++z means increment z and then assign z incremented to j. z++ means asign z to j and then increment it.
For your game, from what I can see you are trying to get the user to enter the letter b , i , r or d to complete the program in under 5 trys. Isn't that a bit too hard aswell?
For your game, from what I can see you are trying to get the user to enter the letter b , i , r or d to complete the program in under 5 trys. Isn't that a bit too hard aswell?
It appears that the purpose of the game is to guess what the uninitialized variables will be set to. I wonder what the odds of winning are.