When I run in visual studio, it says this: error C2447: \'{\' : missing function
ID: 3621971 • Letter: W
Question
When I run in visual studio, it says this:error C2447: '{' : missing function header (old-style formal list?)
and
fatal error C1004: unexpected end-of-file found.
Not sure what I am doing wrong. Please advise:)
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void displayGameMessage()
{
cout << "Welcome to the best guesing game ever! ";
cout << "I am thinking of a number between 1 to 10. ";
cout << "so guess what it is. ";
}
void gameNumberUserPrompt()
{
cout << "How many games would you like to play in our guessing game?" << endl;
}
int myLoopFunction(); //function prototype
int _tmain(int argc, _TCHAR* argv[])
{
int nOuter;
int nRand;
int nGuess;
int totalguesses = 0;
int nGuessCount;
int max = -1;
int min = 100;
int number = -1;
displayGameMessage();
gameNumberUserPrompt();
cin >> nOuter;
myLoopFunction();
cout << "You guess the correct number in " <<nGuessCount << " tries! I was thinking of the number " << nRand << endl;
if (nGuess < min)
min = nGuess;
if (nGuess > max)
max = nGuess;
totalguesses +=nGuess;
cout << endl;
return 0;
}
int myLoopFunction();
{
int i;
srand(time(0));
for (i = 1; i <= nOuter; ++i) //expressions for loop
{
nRand = (rand() % 10) + 1; //random number generator
nGuessCount = 0; //initialized to zero
cout << "Let the guessing game begin! ";
cout << "Game: " << i << endl;
do
{
cout << " next guess: ";
cin >> nGuess;
++nGuessCount;
}
while (nGuess != nRand);
}
Explanation / Answer
please rate - thanks
you had many problems, but the program now works
#include "stdafx.h"
#include
#include
#include
using namespace std;
void displayGameMessage()
{
cout << "Welcome to the best guesing game ever! ";
cout << "I am thinking of a number between 1 to 10. ";
cout << "so guess what it is. ";
}
void gameNumberUserPrompt()
{
cout << "How many games would you like to play in our guessing game?" << endl;
}
int myLoopFunction(int,int); //function prototype
int main()
{
int nOuter;
int i;
int nGuess,nRand;
int totalguesses = 0;
int nGuessCount=0;
int max = -1;
int min = 100;
int number = -1;
displayGameMessage();
gameNumberUserPrompt();
srand(time(0));
nRand = (rand() % 10) + 1; //random number generator
cin >> nOuter;
for (i = 1; i <= nOuter; ++i) //expressions for loop
{
nGuess=myLoopFunction(nRand,i);
cout << "You guess the correct number in " <<< " tries! I was thinking of the number " << nRand << endl;
if (nGuess < min)
min = nGuess;
if (nGuess > max)
max = nGuess;
totalguesses +=nGuess;
}
cout<<"The most guesses a game took was "<<
cout<<"The least guesses a game took was "<<
cout<<"all games took a total of "<<<" guesses ";
cout << endl;
system("pause");
return 0;
}
int myLoopFunction(int nRand,int i)
{
int nGuessCount,nGuess;
nGuessCount = 0; //initialized to zero
cout << "Let the guessing game begin! ";
cout << "Game: " << i << endl;
do
{
cout << " next guess: ";
cin >> nGuess;
++nGuessCount;
}
while (nGuess != nRand);
return nGuessCount;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.