ERRORS

The following game has errors and wont run! Help please.

/*
Guess the computers Number game
*/
//main
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
double firmver = 0.01;; // Game version

cout << "\t\t\tGuess Num " << firmver;
cout << "\nCompete with the computer.\nTry to guess the right number!\nSee how thinks faster!\n\n";
cout << "Do you want to play?(yes/no || y/n)" << endl;

string playgame; // to check if player wants to play
cin >> playgame;
cin.get();

// Does player want to play?
if(playgame == "yes" || playgame == "YES"
|| playgame == "Yes" || playgame == "y"
|| playgame == "Y")
{
cout << "Press any key to start" << endl;

//Game loop
while(playgame == "yes" || playgame == "YES"
|| playgame == "Yes" || playgame == "y"
|| playgame == "Y")
{
int psnum; //player secret num
int csnum; //computer secret num



long pgnum; //player guess num
int cgnum; // computer guess num

int amountpg = 1; // amount player guesses max 3 times per guess
int amountcg = 0; // amount computer guesses max 3 times per guess

psnum = rand() % 50 + 1; // Initiliaze player secret num from 1-50;
csnum = rand() % 50 + 1; // Initiliaze computer secret num from 1-50;
cout << amountpg << endl;

while(amountpg != 3)
{
cout << "Please guess your number" << endl;

cin >> pgnum;

if(pgnum == psnum)
{
cout << "You guessed right" << endl;
amountpg = 0;
}

if (pgnum > psnum)
{
cout << "It is too high" << endl;
amountpg++;
cout << amountpg << endl;
}

if (pgnum < psnum)
{
cout << "It is too low" << endl;
amountpg;
cout << amountpg << endl;
}
}

cout << "You guessed 3 times wrong! Concentrate on solving the next guess" << endl;
psnum = rand() % 50 + 1; // Initiliaze player secret num from 1-50;
amountpg == 0;

}
}
}
use [code] tags
Last edited on
The following game has errors and wont run! Help please.

Instead of us guessing what you obviously already know, please present the text of the errors or describe the behavior of the program and why you believe it is faulty.

"Hey! Guess what's wrong with my program and then tell me how to fix it!" isn't likely to garner many responses. A more descriptive title than "ERRORS" would also be advised.
Topic archived. No new replies allowed.