hello how can i do a for loop .. for a guessing game... and the only 5 oportunities to answer..... forexample no you wrong u have 4 guess left"
heres my code !!1
this one just keeps giving me an unfishing loop grrrr!!!
#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
using namespace std;
void welcome()
{
cout << " welcome to my game i will pick a number between 1 - 50"
<< "and you will try to guess it :)"<< endl;
}
int main()
{
welcome();
int secret_number;
int guess;
bool number;
//4. Seed the pseudo-random generator with the statement:
srand( static_cast<int>( time( NULL ) ) );
secret_number = rand() % 50 + 1;
cout << " please enter a number" << endl;
cin >> guess;
for (int i=0; i<5; i--)
{
int times =5;
{
if (guess== secret_number)
{
cout << " yay you got it"
<< " thanks for playing" <<endl;
}
else if (guess > secret_number)&&(times == i--)
{
cout << " nope guess is too high"
<< " you have" << times<< "left" << endl;
}
else
cout << " you got no more tries :( " << endl;
}
}
return 0;
}