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!