Browse Source

functional 17: checkAnswer (useranswer == 5)

remotes/origin/Christian
Christian Reum 11 months ago
parent
commit
9f69d94d3c
  1. 20
      src/wwm.c
  2. 1
      src/wwm.h

20
src/wwm.c

@ -8,6 +8,8 @@ int geld = 0;
int frage = 0;
int useranswer;
int ceingabe();
int setGeld(int runde){
int Geldstufen[] = {0, 100, 200, 300, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 125000, 250000, 500000, 1000000};
geld = Geldstufen[runde];
@ -22,10 +24,24 @@ int crandomNumber() {
}
void ccheckAnswer(int useranswer) {
if (useranswer == 5) {
printf("That is a shame, but ok.\n");
printf("Congratulations! You have won %d $!", geld);
exit(0);
}
}
int ceingabe() {
printf("Your answer (1-4):");
scanf("%d", &useranswer);
return useranswer;
int result = scanf_s("%d", &useranswer);
if (result == 0) {
printf("Please enter a number beetween 1 and 4 to answer or 5 to end the game!\n");
while (getchar() != '\n')
return ceingabe();
return useranswer;
}
};
void wwm(){

1
src/wwm.h

@ -10,6 +10,7 @@ extern int Geldstufen[];
int crandomNumber();
int ceingabe();
void ccheckAnswer();
int setGeld(int runde);

Loading…
Cancel
Save