Hi, I'm making a program to let a user guess the correct sum of two die, but I keep getting an error that says "Undefined reference to 'Score'." Can someone tell me how to fix it? My code looks like this:
Code:
#include <stdio.h>
#include <time.h>
void main ()
{
{
//Declare variables.
int GameChoice, Guess, Answer, Score(Guess, Answer);
//Ask user to chose a game.
printf("Please chose a game by entering its' number:\nPlay Dice => Enter 1 \nGuess a Number => Enter 2\n");
scanf("%d", &GameChoice);
//If the User chooses to Play Dice
{
int DieTotal, UserGuess;
if (GameChoice == 1)
{
//Let the computer select a number from 2 to 12.
srand(time(0));
DieTotal = 2 + rand() % 11;
//Ask user to select a number between 2 and 12.
printf("Select a number between 2 and 12: ");
scanf("%d", &UserGuess);
Score(Guess, Answer);
}
}
}
int Guess, Answer;
int Score(Guess, Answer)
{
if (Guess == Answer)
{
printf("\nYou won. The sum of the two numbers was %d.\n", Answer);
}
else (Guess != Answer);
{
printf("\nYou lost. The sum of the two numbers was actually %d.\n", Answer);
}
}
}
Comment