PROGRAMME NOT WORKING CORRECTLY IT IS AN ODD-EVE GAME

Aug 15, 2013 at 11:12am
THE PROGRAMME WORKS BUT WHEN IT SAYS "Press '1' to Play Again or '0' to Exit"
it does not work correctly(IT DOES NOT QUITS). PLEASE HELP????????!!!!!!! THE CODE IS:-


#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int main()
{
system("title ODD-EVE GAME");
system("color B0");
string path;
cout<< "WELCOME TO ODD-EVE GAME!!!!!" <<endl <<endl;
cout<<"PLEASE CHOOSE YOUR PATH - ODD OR EVE: ";
cin>> path;
system("cls");
if(path=="eve" || path=="EVE" || path=="Eve"|| path=="eVe" || path=="EvE" || path=="eVE"|| path=="EVe")
{
int num;
srand(time(0));
int j;
j = 1 + (rand()%6);

cout<< "Let's Play ODD-EVE!(YOU ARE EVE) "<<endl <<endl;
Sleep(1000);
cout<< "Enter a number between 1 to 6: ";
cin>> num;

if(num>6 || num<1)
{
cout<< "Invalid" <<endl;
Sleep(1000);
system("cls");
main();
}


cout<< "My number is:" << j <<endl <<endl;
Sleep(1000);

if(j>num)
{
int result;
int pick;
result = j - num;
if(result==2 || result==4)
{
cout<< "You Win!" <<endl <<endl;
}
if(result==1 || result==3 || result==5)
{
cout<< "You Lose!" <<endl<< endl;
}

cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}
}

if(j<num)
{
int result;
int pick;
result = num - j;
if(result==1 || result==3 || result==5)
{
cout<< "You Lose!" <<endl;
}
if(result==2 || result==4)
{
cout<< "You Win!" <<endl <<endl;
}
cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}
}

if(num==j)
{

cout<<"You Win!" <<endl <<endl;
}
int pick;
cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}

getch();

}

if(path=="odd" || path=="ODD" || path=="Odd"|| path=="oDd" || path=="OdD" || path=="oDD"|| path=="ODd")
{
int num;
srand(time(0));
int j;
j = 1 + (rand()%6);

cout<< "Let's Play ODD-EVE!(YOU ARE ODD) "<<endl <<endl;
Sleep(1000);
cout<< "Enter a number between 1 to 6: ";
cin>> num;

if(num>6 || num<1)
{
cout<< "Invalid" <<endl;
Sleep(1000);
system("cls");
main();
}

Sleep(1000);

cout<< "My number is:" << j <<endl <<endl;

if(j>num)
{
int result;
int pick;
result = j - num;
if(result==2 || result==4)
{
cout<< "You Lose!" <<endl <<endl;
}
if(result==1 || result==3 || result==5)
{
cout<< "You Win!" <<endl<< endl;
}

cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}
}

if(j<num)
{
int result;
int pick;
result = num - j;
if(result==1 || result==3 || result==5)
{
cout<< "You Win!" <<endl;
}
if(result==2 || result==4)
{
cout<< "You Lose!" <<endl <<endl;
}
cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}
}

if(num==j)
{

cout<<"You Lose!" <<endl <<endl;
}
int pick;
cout<< "Press '1' to Play Again or '0' to Exit :";
cin>> pick;
if (pick == '1')
{
system("cls");
main();
}
if (pick == '0')
{
MessageBox(0,"Thank You For Playing!\n MADE BY-KANISHK JAYANT LAL","MESSAGE!", MB_OK);
return 0;
}

return 0;
}
return 0;
}
Last edited on Aug 15, 2013 at 11:14am
Aug 15, 2013 at 11:21am
check where you have called main inside main()
second main return to first one and continue further if such is the case
Aug 29, 2013 at 3:11pm
Thnx! It really worked
Topic archived. No new replies allowed.