Can anyone explain why this simple trivia game is not working?
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <ctype.h>
//Trivia Game
//Function Prototypes
int people(void);
int places(void);
void pause(int);
//Global Variables
int answer=0;
//Main
main()
{
do
{
system("clear");
printf("\t\tTrivia Game\n");
printf("\tEnter a Choice:\n");
printf("1.People");
printf("2.Places");
printf("3.Quit");
scanf("%d",answer);
switch(answer)
{
case 1:
if (people()==2)
printf("\nCorrect\n");
else
printf("\nIncorrect\n");
pause(2);
break;
case 2:
if (places()==2)
printf("Correct\n");
else
printf("Incorrect\n");
pause(2);
break;
}
while (answer!=3);
}
}
int places(void){
int choice=0;
printf("What place is warmer?\n");
printf("1.Alaska\n");
printf("2.Hawaii\n");
printf("Pick Your Choice!\n");
scanf("%d",&choice);
pause(2);
return choice;
}
int people(void)
{
int choice=0;
printf("What person was president?\n");
printf("1.Hilary Clinton");
printf("2.Bill Clinton");
scanf("%d",&choice);
pause(2);
return choice;
}
void pause(int inNum)
{
int iCurrentTime=0;
int iElapsedTime=0;
iCurrentTime=time(NULL);
do
{
iElapsedTime = time(NULL);
}
while
((iElapsedTime-iCurrentTime)<inNum);
}