Browse Source

functional 9: for-Schleife für 15 Fragen

remotes/origin/Christian
Christian Reum 11 months ago
parent
commit
318e68a75e
  1. 17
      src/wwm.c

17
src/wwm.c

@ -5,6 +5,7 @@
int runde = 0;
int geld = 0;
int frage = 0;
void wwm(){
printf("Welcome to ´Who wants to be a millionaire?´ \n");
@ -13,24 +14,27 @@ void wwm(){
const char* question[] = {
"Which planet is known as the `blue planet`?",
"What is the capital of Germany?",
"What is the largest desert in the world?"
"What is the largest desert in the world?",
"In which country would you find the Great Wall?",
"How many meters are in a kilometer?"
};
const char* answers[][4] = {
{"Mars", "Venus", "Earth", "Jupiter"},
{"Munich", "Berlin", "Cologne", "Frankfurt am Main"},
{"Antarctica", "Sahara", "Gobi", "Arctica" }
{"Antarctica", "Sahara", "Gobi", "Arctica" },
{"USA", "China", "Russia", "Japan"},
{"100", "10", "1", "1000"}
};
int correctAnswer[] = {
3, 2, 1
3, 2, 1, 2, 4
};
for (r = 1; r <= 15; r++){
srand(time(0));
int frage = rand() % 5;
printf("Question %d: %s\n", runde + 1, question[frage]);
for (int i = 0; i < 4; i++) {
@ -43,11 +47,12 @@ void wwm(){
if (useranswer == correctAnswer[frage]) {
printf("That is correct!");
runde++;
}
else {
printf("That is wrong!");
}
}
return;

Loading…
Cancel
Save