I've been working for hours with this simple code(not for me). Here is the code:
Code:
#include <iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
int cash=10000;
int guess;
int number;
int bet;
int prize=bet*2;
do
{
int clrscr();
play:
std::cout<<"Welcome to the Guess Game.'\n'You have $",cash," in hand.'\n'Place your bet.'\n'";
std::cin>>bet;
if(cash<bet)
{
std::cout<<"You do not have enough money. Please place a lower bet.";
continue;
}
else
{
cash=cash-bet;
std::cout<<"Bet: ",bet," Cash in hand: " ,cash;
}
std::cout<<"I will pick a random number from 0 to 20.";
std::cout<<"You must try to guess the number.";
int randomize();
number=(int)(rand()%20);
do
{
std::cout<<"What is your guess? (0 to 20) ";
std::cin>>guess;
if((guess<0)||(guess>20))
{
std::cout<<"Sorry, but your guess ",guess,"must be from 0 to 20.";
}
else if(guess < number)
{
std::cout<<"Wrong! ",guess," is low. I have picked ",number;
goto play;
}
else if(guess > number)
{
std::cout<<"Wrong! ",guess," is high. I have picked ",number;
goto play;
}
else
{
std::cout<<"Number ",guess," is correct. Congratulations!";
cash=cash+prize;
std::cout<<"You won $",prize," in hand. You now have $",cash;
goto play;
}
if(cash==0);
{
goto lost;
}
lost:
std::cout<<"Thank you for playing Guess Game.'\n'Press ENTER to quit.";
cin.get();
return 0;}
Here is what BloodShed displays on Error Log:
Code:
guessgame.cpp: In function `int main(int, char**)':
guessgame.cpp:70: error: expected `while' at end of input
guessgame.cpp:70: error: expected `(' at end of input
guessgame.cpp:70: error: expected primary-expression at end of input
guessgame.cpp:70: error: expected `)' at end of input
guessgame.cpp:70: error: expected `;' at end of input
guessgame.cpp:70: error: expected `}' at end of input
guessgame.cpp:70: error: expected `while' at end of input
guessgame.cpp:70: error: expected `(' at end of input
guessgame.cpp:70: error: expected primary-expression at end of input
guessgame.cpp:70: error: expected `)' at end of input
guessgame.cpp:70: error: expected `;' at end of input
guessgame.cpp:70: error: expected `}' at end of input
make.exe: *** [guessgame.o] Error 1
Execution terminated