Code wont compile after creating funnction?

I followed the video where you put your introduction into a function and move it to the top, but as soon as I do it, I get an error and the code wont run.

#include <iostream>

PlayerIntroduction()
{
	//Introduction to player
	std::cout << "You are hacking into your school... \n";
	std::cout << "You must answer the correct numbers. \n";
}

void PlayGame()
{
	PlayerIntroduction()

	//Establish variables
	**const** int NumberA = 1;
	const int NumberB = 1;
	const int NumberC = 1;

	const int NumberSum = *NumberA* + NumberB + NumberC;
	const int NumberProduct = NumberA * NumberB * NumberC;

	//Hinting the answer
	std::cout << "+ The numbers add up to " << NumberSum;
	std::cout << "\n+ The numbers multiply to " << NumberProduct;
	std::cout << "\nEnter your answer:";

	//Taking input
	int GuessA, GuessB, GuessC;
	std::cin >> GuessA >> GuessB >> GuessC;
	int GuessSum = GuessA + GuessB + GuessC;
	int GuessProduct = GuessA * GuessB * GuessC;

	//Printing win or loss
	if (NumberSum == GuessSum && NumberProduct == GuessProduct)
	{
		std::cout << "You win!";
	}
	else
	{
		std::cout << "You lose!";
	}

	//End of code
}

int main()
{
	PlayGame();
	return 1;
}

The “const” and “NumberA” instantly get a red underline, but I have no clue how to fix it, please help!

This is missing a return type.

This is missing a semicolon.

1 Like

I feel so stupid now… sorry and thank you for the response

No worries :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms