i just received some help from zandiago it his help was great and i thank you. when i incorporated the info into my program i received an error when building the solution. it was only one error. it was

error C2447: '{' : missing function header (old-style formal list?)

the error was at {(in red) How do i fix that and could you please explain how you fix it. thank you. i really appreciate everyones help with my project. this is a great place to learn with the help of others. here is my program. any help or ideas is greatly appreciated

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main ()
;int playSomeGames();
{ //< here
    int num;
    int guess;
    bool done;
    int noOfGuesses=0;
    int ncount;
    int sum=0;
    int noofgamesplayed = 0;
    int avgNoOfGuesses; 
    noofgamesplayed++;

void playSomeGames( ) {
  int numGamesPlayed = 0;
  do {
    playAGame();
    numGamesPlayed++;
  } while ( again );
  cout << "You played " << numGamesPlayed << " games";
}

void playOneGame ( ) {
  int numGuesses = 0;
  do {

  } while ( numGuesses < 10 );
  cout << "You took " << numGuesses << " to guess";
}int main ( ) {
  playSomeGames();
  return 0;
}

void playSomeGames( ) {
  int numGamesPlayed = 0;
  do {
    playAGame();
    numGamesPlayed++;
  } while ( again );
  cout << "You played " << numGamesPlayed << " games";
}

void playOneGame ( ) {
  int numGuesses = 0;
  // generate a target value
  do {
    // prompt for guess etc
  } while ( numGuesses < 10 );
  cout << "You took " << numGuesses << " to guess";
}

 sum += noOfGuesses;
     avgNoOfGuesses=sum/noofgamesplayed;
    srand((unsigned)time(0))
    ;num = (rand() % 1000);
    done = false;
    while ((noOfGuesses < 10) && (!done))

    {
        cout << "Enter an integer greater"
            << " than or equal to 0 and "
            << "less than 1000: ";
        cin >> guess;
        cout << endl;
        noOfGuesses++;
        if (guess == num)
        {
            cout << "you guessed the correct "
                << "number." << endl;
            done = true;
        }
        else
            if (guess < num)
                cout << "Your guess is lower "
                << "than the number. \n"
                << "Guess again!" << endl;
            else
                cout << "Your guess is higher "
                << "than the number.\n"
                << "guess again!" << endl;
            cout <<"Total gueses equal " << noOfGuesses << endl;
            cout << "you played " << noofgamesplayed << " games";



    }
    return 0;
    }

Recommended Answers

All 2 Replies

>>any help or ideas is greatly appreciated

Don't blindly copy and paste and expect the code to work. It sends a pretty loud message, that most people don't want to hear.

If you want to use functions, then use them, but don't just slap into your program somewhere.

For now, I suggest you remove everything that has to do with functions other than main(), redeclare your variables and make sure they are all initalized before you try to use them. Zandiago gave you a good example of how to do it.

Also, keep all posts having to do with the same assignment in one thread.

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.