the program is running well but concept is wrong.
you should find number 0-100 until 10 trials.
if failed, and want to play again unfortunately program is terminated why ?
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
int sayiturev (int aralik) // generating number 1-100
{
srand(GetTickCount());
int sayi=rand()%aralik;
return sayi;
}
int tekrar () // replay decision
{
int karar;
cout << "do you want to play ? yes-1 no-0"<<endl;
cin>>karar;
return karar;
}
int main(int argc, char *argv[])
{
int sayi1;
int sayi2,sor,karar2,son;
int xxx=9;
system("color 3a");
sayi1=sayiturev(100);
sor:
if (xxx==0) goto son;
else
{
do
{
cout << "enter numner=";
cin >> sayi2; // number input for guess
if (sayi2==sayi1)
{
cout << "congratulation....it is correct "<<10-xxx<<".counter\n"<<endl;
xxx=10;
karar2=tekrar();
sayi1=sayiturev(100); // number generator.
}
else if (sayi2<sayi1)
{
cout << "enter more than this \n \n";
xxx--;
goto sor;
}
else if (sayi2>sayi1)
{
cout << "enter less than this \n \n";
xxx--;
goto sor;
}
} while(karar2==1);
system("PAUSE");
return EXIT_SUCCESS;
}
son:
{
cout << "you did not find \n \n";
cout << "number was=" << sayi1;
karar2=tekrar ();
}
}