You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1331 lines
45 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #include <stdbool.h>
  7. #include "quizproject.h"
  8. char answers[NUM_QUESTIONS] = {'B', 'A', 'A','B','A'};
  9. int* randomNumber() {
  10. srand(time(NULL));
  11. int k = 0, p;
  12. static int arr[13];
  13. while(k<13){
  14. int num =rand()%13;
  15. for (p = 0; p < k; p++){
  16. if(arr[p]==num){
  17. break;
  18. }
  19. }
  20. if(p==k){
  21. arr[k++]=num;
  22. }
  23. }
  24. return arr;
  25. }
  26. //-------smart_brain_quiz_begin----------
  27. void e_press_key_start() {
  28. char e_start_game;
  29. scanf(" %c", &e_start_game);
  30. e_start_game = toupper(e_start_game);
  31. }
  32. void e_display_instruction() {
  33. printf("\t\t-------------------------------------------------------\n");
  34. printf("\t\t To start this Quiz, here are the instructions\n");
  35. printf("\t\t------------------------------------------------------\n\n");
  36. printf("\t\t>>In the first, second Round, you answer True or false questions.<<\n\n");
  37. printf("\t\t-------------------------------------------------------\n\n");
  38. printf("\t\t>>Press any key and enter to begin the Quiz.<<\n\n");
  39. e_press_key_start();
  40. }
  41. void e_usr_answr(char question[][100], char ans[], int initial, int end){
  42. int i;
  43. char user_answer;
  44. for(i = initial; i < end; i++) {
  45. printf("[%d]. %s", i + 1, question[i]);
  46. scanf(" %c", &user_answer);
  47. user_answer = toupper(user_answer);
  48. while (user_answer != 'T' || user_answer != 'F' ){
  49. if(user_answer == 'T' || user_answer == 'F') {
  50. break;
  51. } else {
  52. printf("Input is invalid! Enter 'T' for true or 'F' for false [T/F]:\n");
  53. scanf(" %c", &user_answer);
  54. user_answer = toupper(user_answer);
  55. }
  56. }
  57. bool ans1 = e_true_false(user_answer);
  58. if(ans1 == ans[i]) {
  59. score++;
  60. track_r2_score++;
  61. if(track_r2_score >= 2) {
  62. track_r2_score = 0;
  63. }
  64. correct(score);
  65. } else{
  66. wrong(score);
  67. }
  68. }
  69. }
  70. void e_t_f_printQuestions(char askquestion[][100],char answers[]) {
  71. int track_rounds = 0;
  72. while(track_rounds < 1){
  73. printf("\t\t---------------------------Round1-----------------------------\n");
  74. printf("\t\t >>In this round you will be presented with 3 questions.<<\n");
  75. printf("\t\t--------------------------------------------------------------\n\n");
  76. int init = 0, end = 3;
  77. e_usr_answr(askquestion,answers, init, end);
  78. if(score < 2) {
  79. break;
  80. } else {
  81. printf("\t\t---------------------------Round2-----------------------------\n");
  82. printf("\t\t >>In this round you will be presented with 2 questions.<<\n");
  83. printf("\t\t--------------------------------------------------------------\n\n");
  84. init = 3, end = 5;
  85. e_usr_answr(askquestion,answers, init, end);
  86. }
  87. track_rounds++;
  88. }
  89. }
  90. void e_ask_questions(void) {
  91. char e_t_f_question[][100] = {
  92. "Mount Everest is the tallest mountain in the world:\n [T/F]: ",
  93. "USA has the largest population in the world:\n [T/F]: ",
  94. "Russia is the largest country by land size:\n [T/F]: ",
  95. "Donald trump is the current president of USA:\n [T/F]: ",
  96. "Cheese are made from plants:\n [T/F]: ",
  97. "Tomato ist a fruit:\n [T/F]: ",
  98. "Men have 2 X chromosomes:\n [T/F]: "
  99. };
  100. char e_t_f_solution[100] = {
  101. true,
  102. false,
  103. true,
  104. false,
  105. false,
  106. true,
  107. false
  108. };
  109. e_t_f_printQuestions(e_t_f_question, e_t_f_solution);
  110. }
  111. bool e_true_false(char choice) {
  112. if (choice == 'T') {
  113. return true;
  114. } else if(choice == 'F') {
  115. return false;
  116. } else {
  117. return -1;
  118. }
  119. }
  120. void e_questions_r3(void) {
  121. char questions[][100] ={
  122. "Which country started WW3?\n",
  123. "What is the strongest Metal in the world?\n",
  124. "which holy City do Muslim go on a pilgrimage to? \n"
  125. };
  126. char answers [][100] = {
  127. "germany",
  128. "tungsten",
  129. "mecca"
  130. };
  131. e_printout_r3 (questions, answers);
  132. }
  133. void e_printout_r3 (char question[][100], char answers[][100]) {
  134. int i;
  135. char user_answer[100];
  136. printf("\t\t---------------------------Round3-----------------------------\n");
  137. printf("\t\t >>In this round you will be presented with 3 questions.<<\n");
  138. printf("\t\t--------------------------------------------------------------\n\n");
  139. for(i = 0; i < 3; i++) {
  140. int k = 0;
  141. printf("[%d]. %s",i+6,question[i]);
  142. printf(" Your answer: ");
  143. scanf("%s", user_answer);
  144. int num = strlen(user_answer);
  145. char ans[50];
  146. for (int j = 0; j < 9; j++) {
  147. ans[j] = answers[i][j];
  148. }
  149. for (int j = 0; j < strlen(ans); j++) {
  150. if (ans[j] == tolower(user_answer[j])){
  151. k++;
  152. }
  153. }
  154. if (k == strlen(ans) && num == strlen(ans)) {
  155. score++;
  156. correct(score);
  157. } else {
  158. wrong(score);
  159. }
  160. }
  161. }
  162. void e_smart_brain() {
  163. e_display_instruction();
  164. e_ask_questions();
  165. if(score >=4 && track_r2_score ==0) {
  166. e_questions_r3();
  167. }
  168. score = 0;
  169. track_r2_score = 0;
  170. }
  171. //-------smart_brain_quiz_end------------
  172. void displayWelcomeMessage(void) {
  173. displayGameInstructions();
  174. }
  175. void displayGoodLuckMessage(void) {
  176. printf("\t\t------------------------------------------\n\n");
  177. printf("\t\t------------------------------------------\n\n");
  178. printf("\t\t GOOD LUCK! \n\n");
  179. printf("\t\t------------------------------------------\n");
  180. printf("\t\t------------------------------------------\n\n");
  181. }
  182. void displayGameInstructions(void) {
  183. printf("\t\t------------------------------------------\n");
  184. printf("\t\t Welcome to Quiz Game!\n\n");
  185. printf("\t\t------------------------------------------\n\n");
  186. printf("\t\t To start this game, here are the Instructions\n\n");
  187. printf("\t\t------------------------------------------\n");
  188. printf("\t\t------------------------------------------\n\n");
  189. printf("\t\t>>You will be presented with questions from\n");
  190. printf("\t\tRound 1 to Round 3(Easy rounds) and Round\n");
  191. printf("\t\t4 to Round 5(Hard rounds).<<\n");
  192. printf("\t\t>>For every question you have four options (A, B, C, D).<<\n");
  193. printf("\t\t>>For each question, you can either choose the\n");
  194. printf("\t\tanswer from the four options or use a lifeline.<<\n\n");
  195. printf("\t\t>>To Pass Through Round 1: You have to get 3 out of 5 correct.<<\n");
  196. printf("\t\t>>To Pass Through Round 2: You have to get 3 out of 5 correct.<<\n");
  197. printf("\t\t>>To Pass Through Round 3: You have to get 4 out of 5 correct.<<\n");
  198. printf("\t\t>>To Pass Through Round 4: You have to get 4 out of 5 correct.<<\n");
  199. printf("\t\t>>To Pass Through Round 5: You have to get 5 out of 5 correct.<<\n\n");
  200. printf("\t\t>>If you choose the wrong answer, you lose a point.<<\n\n");
  201. printf("\t\tYou may lose the game if not you don't have enough points to pass to the next round.\n\n");
  202. printf("\t\tIf you use a lifeline and still choose the wrong answer, you lose the game.\n");
  203. }
  204. void displayLifelineInstructions(void) {
  205. printf("\t\t>>You have the following lifelines available:<< \n");
  206. printf("\t\t>>'F' 50-50: Eliminates two incorrect answers.<< \n");
  207. printf("\t\t>>'H' Hint: Reveals a hint for the answer.<<\n");
  208. }
  209. void displayInstructions(void) {
  210. displayWelcomeMessage();
  211. displayLifelineInstructions();
  212. displayGoodLuckMessage();
  213. }
  214. void correct(int score2){
  215. printf("\nCorrect!\n");
  216. printf("You have %d points now\n\n", score);
  217. }
  218. void wrong(int score1){
  219. printf("\nWrong!\n");
  220. printf("You have %d points now\n\n", score);
  221. }
  222. void fifty_fifty(int question_num) {
  223. char qC[][100] = {
  224. "A.Mount Everest\nB.Uludag",
  225. "A.USA\nB.China",
  226. "C.Amazon River\nD.The Nile River",
  227. "A.San Fransisco\nB.San Diego",
  228. "C.Merida\nD.Mexico city",
  229. "C.Russia\nD.USA\n",
  230. "A.Alaska\nB.Washington",
  231. "C.Toronto\nD.Ottawa",
  232. "A.Egypt\nB.Mexico",
  233. "A.Surat Thani\nB.Bangkok",
  234. "B.Mexico\nC.USA",
  235. "C.Venice\nD.Naples",
  236. "B.Cluny\nC.The Louvre"
  237. };
  238. printf("%s\n",qC[question_num]);
  239. }
  240. void hintForHardQuestions(int question_num) {
  241. char hints[NUM_QUESTIONS][256] = {
  242. "The city is known for its iconic landmarks and romantic atmosphere.",
  243. "He was a general in the American Revolutionary War and is considered the Father of His Country.",
  244. "This team has won the most NBA championships in history, with a total of 16 championships.",
  245. "It is the lightest and most abundant chemical element in the universe.",
  246. "This South Korean film became the first non-English language film to win the Academy Award for Best Picture."
  247. };
  248. printf("Hint: %s\n", hints[question_num]);
  249. }
  250. void fifty_fifty1(int question_num) {
  251. char options[NUM_QUESTIONS][4][256] = {
  252. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  253. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  254. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  255. { "A) He", "B) H", "C) O", "D) Ne" },
  256. { "A) Parasite", "B) Joker", "C) Once Upon a Time in Hollywood", "D) 1917" }
  257. };
  258. char correct_answer = answers[question_num];
  259. int num_incorrect = 0;
  260. int incorrect_indices[2];
  261. for (int i = 0; i < 4; i++) {
  262. if (options[question_num][i][0] != correct_answer) {
  263. incorrect_indices[num_incorrect] = i;
  264. num_incorrect++;
  265. }
  266. if (num_incorrect == 2) {
  267. break;
  268. }
  269. }
  270. for (int i = 0; i < 2; i++) {
  271. options[question_num][incorrect_indices[i]][0] = '\0';
  272. }
  273. // display remaining options
  274. for (int i = 0; i < 4; i++) {
  275. if (options[question_num][i][0] != '\0') {
  276. printf("%s\n", options[question_num][i]);
  277. }
  278. }
  279. }
  280. void printOutOption(char qS[][100], char qC[][100],char aS[], int initial, int end, int ranArr[]){
  281. char response;
  282. for (int i = initial; i < end; i++){
  283. int randNum = ranArr[i];
  284. printf("[%d] %s\n", i+1, qS[randNum]);
  285. printf("%s\n", qC[randNum]);
  286. printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): ");
  287. scanf(" %c", &response);
  288. response = toupper(response);
  289. if (response == 'F') {
  290. fifty_fifty(randNum);
  291. printf("Enter your answer (A, B, C, or D): ");
  292. scanf(" %c", &response);
  293. response = toupper(response);
  294. }
  295. else if (response == 'H') {
  296. hint(randNum);
  297. printf("Enter your answer (A, B, C, or D): ");
  298. scanf(" %c", &response);
  299. response = toupper(response);
  300. }
  301. if(response == aS[randNum]){
  302. score++;
  303. correct(score);
  304. } else {
  305. wrong(score);
  306. }
  307. }
  308. }
  309. void looping(char qS[][100], char qC[][100], char aS[], int randArr[]){
  310. int k = 0;
  311. while(k < 1){
  312. printf("\t\t--------------------Round 1-------------------\n\n");
  313. printf(">>In this round you need to answer 3 questions correctly to move to Round 2<<\n\n");
  314. int initial = 0, end = 2;
  315. printOutOption(qS,qC,aS,initial,end,randArr);
  316. if (score < 1) {
  317. printf("You lost! Better luck next time\n");
  318. break;
  319. } else {
  320. printf("\t\t--------------------Round 2-------------------\n\n");
  321. printf(">>In this round you need to answer 2 questions correctly to move to Round 3<<\n\n");
  322. initial = 2, end = 4;
  323. printOutOption(qS,qC,aS,initial,end,randArr);
  324. }
  325. if (score < 1) {
  326. printf("You lost! Better luck next time\n");
  327. break;
  328. } else {
  329. printf("\t\t--------------------Round 3-------------------\n\n");
  330. printf(">>In this round you need to answer 2 questions correctly to move to Round 4<<\n\n");
  331. initial = 4, end = 7;
  332. printOutOption(qS,qC,aS,initial,end,randArr);
  333. }
  334. k++;
  335. }
  336. if (score < 2) {
  337. printf("\nYour final score: %d\n", score);
  338. }
  339. }
  340. void ask_questions(void) {
  341. char questions[][100] = {
  342. "What is the name of the tallest mountain in the world?\n",
  343. "Which country has the largest population in the world??\n",
  344. "What is the name of the longest river in Africa?\n",
  345. "What American city is the Golden Gate Bridge located in?\n",
  346. "What is the capital of Mexico?\n",
  347. "What is the name of the largest country in the world?\n",
  348. "What U.S. state is home to no documented poisonous snakes?\n",
  349. "What is the capital of Canada?\n",
  350. "What country are the Great Pyramids of Giza located in?\n",
  351. "What is the capital of Thailand?\n",
  352. "In which country was Frida Kahlo born?\n",
  353. "What present-day Italian city does Mt. Vesuvius overlook?\n",
  354. "The Mona Lisa by Leonardo da Vinci is on display in which Paris museum?\n"
  355. };
  356. char possible_options[][100] = {
  357. "A.Mount Everest\nB.Uludag\nC.K2\nD.Makalu",
  358. "A.USA\nB.China\nC.Russia\nD.India",
  359. "A.Missisipi River\nB.Yangtze River\nC.Amazon River\nD.The Nile River",
  360. "A.San Fransisco\nB.San Diego\nC.New York\nD.Los Angeles",
  361. "A.Oaxaca\nB.Puebla\nC.Merida\nD.Mexico city",
  362. "A.India\nB.China\nC.Russia\nD.USA",
  363. "A.Alaska\nB.Washington\nC.Ohio\nD.California",
  364. "A.Vancouver\nB.Montreal\nC.Toronto\nD.Ottawa",
  365. "A.Egypt\nB.Mexico\nC.Iceland\nD.Greenland",
  366. "A.Surat Thani\nB.Bangkok\nC.Phuket\nD.Pattaya City",
  367. "A.Austria\nB.Mexico\nC.USA\nD.India",
  368. "A.Milan\nB.Rome\nC.Venice\nD.Naples",
  369. "A.Carnavalet\nB.Cluny\nC.The Louvre\nD.Musee d'Orsay"
  370. };
  371. char answers[100] = {
  372. 'A',
  373. 'B',
  374. 'D',
  375. 'A',
  376. 'D',
  377. 'C',
  378. 'A',
  379. 'D',
  380. 'A',
  381. 'B',
  382. 'B',
  383. 'D',
  384. 'C'
  385. };
  386. int* randArr = randomNumber();
  387. looping(questions, possible_options, answers, randArr);
  388. }
  389. void ask_hard_questions(void) {
  390. int k = 0;
  391. while (k < 1) {
  392. int *lessFive = randomNumber();
  393. int arr[5];
  394. int p = 0;
  395. for(int i = 0; i < 13; i++){
  396. if(lessFive[i] < 5){
  397. arr[p] = lessFive[i];
  398. p++;
  399. }
  400. }
  401. printf("\t\t--------------------Round 4-------------------\n\n");
  402. printf(">>In this round you need to answer 2 questions correctly to move to Round 5<<\n\n");
  403. char questions[NUM_QUESTIONS][256] = {
  404. "What is the capital of France?",
  405. "Who was the first president of the United States?",
  406. "Which team won the most NBA championships?",
  407. "What is the chemical symbol for hydrogen?",
  408. "Which of the following movies won the Academy Award for Best Picture in 2020?"
  409. };
  410. char options[NUM_QUESTIONS][4][256] = {
  411. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  412. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  413. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  414. { "A) He", "B) H", "C) O", "D) Ne"},
  415. { "A) Parasite", "B) Joker", "C) Once Upon a Time in Hollywood", "D) 1917" }
  416. };
  417. char user_answers[NUM_QUESTIONS];
  418. int lifelines[NUM_QUESTIONS] = { 1, 1,1,1,1};
  419. int randNum;
  420. for (int i = 0; i < 3; i++) {
  421. randNum = arr[i];
  422. printf("[%d] %s\n", i + 1, questions[randNum]);
  423. for (int j = 0; j < 4; j++) {
  424. printf("%s\n", options[randNum][j]);
  425. }
  426. printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): ");
  427. char response;
  428. scanf(" %c", &response);
  429. response = toupper(response);
  430. if (response == 'F' && lifelines[i] == 1) {
  431. fifty_fifty1(randNum);
  432. printf("Enter your answer (A, B, C, or D): ");
  433. scanf(" %c", &user_answers[randNum]);
  434. user_answers[randNum] = toupper(user_answers[randNum]);
  435. lifelines[i] = 0;
  436. }else if (response == 'H' && lifelines[i] == 1) {
  437. hintForHardQuestions(randNum);
  438. printf("Enter your answer (A, B, C, or D): ");
  439. scanf(" %c", &user_answers[randNum]);
  440. user_answers[randNum] = toupper(user_answers[randNum]);
  441. lifelines[i] = 0;
  442. }else {
  443. user_answers[randNum] = response;
  444. }
  445. if (user_answers[randNum] == answers[randNum]) {
  446. score++;
  447. correct(score);
  448. } else {
  449. wrong(score);
  450. }
  451. }
  452. if ( score < 4) {
  453. printf("You lost! Better luck next time\n");
  454. break;
  455. } else {
  456. printf("\t\t--------------------Round 5-------------------\n\n");
  457. printf(">>This is the final round. Good Luck!<<\n\n");
  458. for (int i = 3; i < 5; i++) {
  459. randNum = arr[i];
  460. printf("[%d] %s\n", i + 1, questions[randNum]);
  461. for (int j = 0; j < 4; j++) {
  462. printf("%s\n", options[randNum][j]);
  463. }
  464. printf("Enter your answer (A, B, C, or D) or use a lifeline (F for 50/50, H for hint): ");
  465. char response;
  466. scanf(" %c", &response);
  467. response = toupper(response);
  468. if (response == 'F' && lifelines[i] == 1) {
  469. fifty_fifty1(randNum);
  470. printf("Enter your answer (A, B, C, or D): ");
  471. scanf(" %c", &user_answers[randNum]);
  472. user_answers[randNum] = toupper(user_answers[randNum]);
  473. lifelines[i] = 0;
  474. }else if (response == 'H' && lifelines[i] == 1) {
  475. hintForHardQuestions(randNum);
  476. printf("Enter your answer (A, B, C, or D): ");
  477. scanf(" %c", &user_answers[randNum]);
  478. user_answers[randNum] = toupper(user_answers[randNum]);
  479. lifelines[i] = 0;
  480. }else {
  481. user_answers[randNum] = response;
  482. }
  483. // check each answer
  484. if (user_answers[randNum] == answers[randNum]) {
  485. score++;
  486. correct(score);
  487. } else {
  488. wrong(score);
  489. }
  490. }
  491. }
  492. k++;
  493. }
  494. printf("\nYour final score: %d\n", score);
  495. }
  496. void hint(int question_num) {
  497. char qC[][100] = {
  498. "Hint:The Tallest mountain is 8,849m.",
  499. "Hint:It's population is 1.412 billion.",
  500. "Hint:The longest river measures 6,650km.",
  501. "Hint:The Golden States Warriors play there.\n",
  502. "Hint:It is one of the oldest and largest cities in the Americas.\n",
  503. "Hint:The area of the largest country is 17.1 million km2.\n",
  504. "Hint:It is the coldest state in the US.",
  505. "Hint:It is the 4th largest city in Canada.",
  506. "Hint:It is a dry Country.",
  507. "Hint:The capital has the longest city name in the world.",
  508. "Hint:The Native language is Spanish.",
  509. "Hint:The city that invented Swamp Buggy Racing.",
  510. "Hint:It is the most visited art museum in the world."
  511. };
  512. printf("%s\n",qC[question_num]);
  513. }
  514. void displayThankYouMessage(void) {
  515. printf("*******************************\n");
  516. printf("Thank you for playing QuizGame!\n");
  517. printf("*******************************\n\n");
  518. }
  519. void play_quizgame(void){
  520. displayInstructions();
  521. printf(">>Press 's' and Enter to start the Game<<\n");
  522. char var, var1 = 's';
  523. getchar();
  524. while(var != var1) {
  525. var = getchar();
  526. }
  527. printf("\n");
  528. ask_questions();
  529. if (score > 2){
  530. ask_hard_questions();
  531. }
  532. displayThankYouMessage();
  533. }
  534. void v_factorlie(void){
  535. char statements[][100] = {
  536. "Tomatoes are fruits.", // fact
  537. "The Great Wall of China is visible from space.", // lie
  538. "Water freezes at 0 degrees Celsius.", // fact
  539. "Napoleon Bonaparte ruled Germany at a time in history.", // fact
  540. "Barack Obama was born in America." // lie
  541. };
  542. char answers[] = {'F','L','F','F','L'}; // L for lie, F for fact
  543. int num_statements = sizeof(statements) / sizeof(statements[0]);
  544. int score = 0;
  545. printf("\nWelcome to the Fact or Lie Quiz!\n\n");
  546. for (int i = 0; i < num_statements; i++) {
  547. char user_answer;
  548. printf("Statement %d: %s\n\n", i + 1, statements[i]);
  549. printf("Is this statement a fact (F) or a lie (L)?\n");
  550. printf("Your answer: \n");
  551. scanf(" %c", &user_answer);
  552. user_answer = toupper(user_answer);
  553. if (user_answer == answers[i]) {
  554. score++;
  555. printf("Correct! You get a point.\n\n");
  556. } else {
  557. printf("Sorry, its incorrect. No points!\n\n");
  558. }
  559. }
  560. printf("Your final score is %d out of %d.\n", score, num_statements);
  561. }
  562. void play_factorlie() {
  563. printf("**********************\n");
  564. printf("Playing Fact or Lie!\n");
  565. printf("**********************\n");
  566. v_factorlie();
  567. printf("**********************************\n");
  568. printf("Thank you for playing Fact or Lie!\n");
  569. printf("**********************************\n");
  570. }
  571. void play_milliongame() {
  572. printf("Playing who wants to be a millionaire...\n");
  573. int million_i = 0, million_k = 0;;
  574. char million_user_answers[round];
  575. char million_std_answers[round] = {'B', 'A', 'A','B', 'A', 'A','B', 'A', 'A','B', 'A', 'A','B', 'A', 'A'};
  576. int million_stay_in_game = 0, million_reward = 0, million_checkpoint = 0, million_count_replace = 0;
  577. int million_lifeline_hint = 1, million_lifeline_delete = 1, million_lifeline_friend = 1;
  578. char questions[round][256] = {
  579. "What is the capital of France?",
  580. "Who was the first president of the United States?",
  581. "Which team won the most NBA championships?",
  582. "What is the capital of France?",
  583. "Who was the first president of the United States?",
  584. "Which team won the most NBA championships?",
  585. "What is the capital of France?",
  586. "Who was the first president of the United States?",
  587. "Which team won the most NBA championships?",
  588. "What is the capital of France?",
  589. "Who was the first president of the United States?",
  590. "Which team won the most NBA championships?",
  591. "What is the capital of France?",
  592. "Who was the first president of the United States?",
  593. "Which team won the most NBA championships?"
  594. };
  595. char answers[round][4][256] = {
  596. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  597. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  598. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  599. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  600. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  601. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  602. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  603. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  604. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  605. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  606. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  607. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" },
  608. { "A) Berlin", "B) Paris", "C) London", "D) Rome" },
  609. { "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" },
  610. { "A) Los Angeles Lakers", "B) Chicago Bulls", "C) Golden State Warriors", "D) Boston Celtics" }
  611. };
  612. while(million_i < round && million_stay_in_game == 0){
  613. printf("You have %d:Fifty/Fifty\t%d:Phone a Friend\t%d:Hint\t\n",million_lifeline_delete,million_lifeline_friend,million_lifeline_hint);
  614. printf("\n%s\n",questions[million_i]);
  615. for(int j=0;j<4;j++){
  616. printf("%s\n",answers[million_i][j]);
  617. }
  618. point_one:
  619. printf("Enter a valid Response: ");
  620. scanf(" %c", &million_user_answers[million_i]);
  621. million_user_answers[million_i] = toupper(million_user_answers[million_i]);
  622. switch(million_user_answers[million_i]){
  623. case 'A':
  624. if(million_user_answers[million_i] == million_std_answers[million_i]){
  625. printf("\nCorrect!");
  626. million_reward = million_reward + (10000 * (million_i+1));
  627. printf("\n%d\n",million_reward);
  628. if(million_i == 0){
  629. million_checkpoint = 0;
  630. }
  631. else if(million_i == 4){
  632. million_checkpoint = million_reward;
  633. }
  634. else if(million_i == 9)
  635. million_checkpoint = million_reward;
  636. else{}
  637. }
  638. else{
  639. printf("\nIncorrect!");
  640. million_stay_in_game == 1;
  641. }
  642. break;
  643. case 'B':
  644. if(million_user_answers[million_i] == million_std_answers[million_i]){
  645. million_reward = million_reward + (10000 * (million_i+1));
  646. printf("\n%d\n",million_reward);
  647. printf("\nCorrect!");
  648. if(million_i == 0){
  649. million_checkpoint = 0;
  650. }
  651. else if(million_i == 4){
  652. million_checkpoint = million_reward;
  653. }
  654. else if(million_i == 9)
  655. million_checkpoint = million_reward;
  656. else{}
  657. }
  658. else{
  659. printf("\nIncorrect!");
  660. million_stay_in_game == 1;
  661. }
  662. break;
  663. case 'C':
  664. if(million_user_answers[million_i] == million_std_answers[million_i]){
  665. million_reward = million_reward + (10000 * (million_i+1));
  666. printf("\n%d\n",million_reward);
  667. printf("\nCorrect!");
  668. if(million_i == 0){
  669. million_checkpoint = 0;
  670. }
  671. else if(million_i == 4){
  672. million_checkpoint = million_reward;
  673. }
  674. else if(million_i == 9)
  675. million_checkpoint = million_reward;
  676. else{}
  677. }
  678. else{
  679. printf("\nIncorrect!");
  680. million_stay_in_game == 1;
  681. }
  682. break;
  683. case 'D':
  684. if(million_user_answers[million_i] == million_std_answers[million_i]){
  685. million_reward = million_reward + (10000 * (million_i+1));
  686. printf("\n%d\n",million_reward);
  687. printf("\nCorrect!");
  688. if(million_i == 0){
  689. million_checkpoint = 0;
  690. }
  691. else if(million_i == 4){
  692. million_checkpoint = million_reward;
  693. }
  694. else if(million_i == 9)
  695. million_checkpoint = million_reward;
  696. else{}
  697. }
  698. else{
  699. printf("\nIncorrect!");
  700. million_stay_in_game == 1;
  701. }
  702. break;
  703. case 'H':
  704. if(million_lifeline_hint != 1){
  705. printf("\nHint already used\n");
  706. goto point_one;
  707. } else {
  708. million_lifeline_hint = 0;
  709. printf("Hint would be displayed here\n");
  710. goto point_one;
  711. }
  712. break;
  713. case 'F':
  714. if(million_lifeline_delete != 1){
  715. printf("\nFifty/Fifty lifeline already used\n");
  716. goto point_one;
  717. }
  718. else {
  719. million_lifeline_delete = 0;
  720. printf("\nComputer will now MARK two wrong answers...\n");
  721. while(million_k < 4 && million_count_replace < 2){
  722. if(answers[million_i][million_k][0] != million_std_answers[million_i]){
  723. answers[million_i][million_k][0] = 'X';
  724. million_count_replace = million_count_replace + 1;
  725. }
  726. million_k++;
  727. }
  728. for(int million_n = 0; million_n < 4; million_n++){
  729. printf("%s\n",answers[million_i][million_n]);
  730. }
  731. goto point_one;
  732. }
  733. break;
  734. case 'P':
  735. if(million_lifeline_friend != 1){
  736. printf("\nLifeline Friend already used\n");
  737. goto point_one;
  738. }
  739. else{
  740. million_lifeline_friend = 0;
  741. printf("\nYou can now ask a friend for help...\n");
  742. for(int j=0;j<4;j++){
  743. printf("%s\n",answers[million_i][j]);
  744. }
  745. goto point_one;
  746. }
  747. break;
  748. case 'T':
  749. million_stay_in_game = 1;
  750. break;
  751. default:
  752. goto point_one;
  753. }
  754. million_i++;
  755. }
  756. printf("\n%d\n",million_checkpoint);
  757. // code for game 3 goes here
  758. }
  759. void v_guessingGame(void){
  760. int secret_number, guess;
  761. srand(time(NULL));
  762. secret_number = rand() % 100 + 1;
  763. printf("Guess the Number!\n\n");
  764. printf("I am thinking of a number between 1 and 100. Can you guess what it is?\n");
  765. while (1) {
  766. printf("Enter your guess: ");
  767. scanf("%d", &guess);
  768. if (guess > secret_number) {
  769. printf("Too high! Try again.\n");
  770. } else if (guess < secret_number) {
  771. printf("Too low! Try again.\n");
  772. } else {
  773. printf("Congratulations, you found the secret number!\n");
  774. break;
  775. }
  776. }
  777. }
  778. void play_guessingGame() {
  779. printf("*************************\n");
  780. printf("Playing Guess the Number!\n");
  781. printf("*************************\n\n");
  782. v_guessingGame();
  783. printf("****************************************\n");
  784. printf("Thank you for playing Guess the Number!\n");
  785. printf("****************************************\n");
  786. }
  787. void v_guessTheWord(char word[], char guessed[]) {
  788. int i;
  789. for (i = 0; i < strlen(word); i++) {
  790. if (guessed[i]) {
  791. printf("%c ", word[i]);
  792. } else {
  793. printf("_ ");
  794. }
  795. }
  796. printf("\n");
  797. }
  798. void play_guessTheWord() {
  799. char word[] = "Fulda";
  800. char guessed[MAX_WORD_LENGTH] = {0};
  801. int lives = MAX_LIVES;
  802. int word_length = strlen(word);
  803. char guess;
  804. guess = toupper(guess);
  805. printf("***********************\n");
  806. printf("Playing Guess the Word!\n");
  807. printf("***********************\n\n");
  808. printf("IMPORTANT: The first letter is a capital letter!\n\n");
  809. while (lives > 0) {
  810. int i;
  811. int correct = 0;
  812. printf("Lives: %d\n", lives);
  813. v_guessTheWord(word, guessed);
  814. printf("Guess a letter: ");
  815. scanf(" %c", &guess);
  816. for (i = 0; i < word_length; i++) {
  817. if (word[i] == guess) {
  818. guessed[i] = guess;
  819. correct = 1;
  820. }
  821. }
  822. if (!correct) {
  823. lives--;
  824. }
  825. if (strcmp(word, guessed) == 0) {
  826. printf("You win! The word was: %s\n\n", word);
  827. printf("*************************************\n");
  828. printf("Thank you for playing Guess the Word!\n");
  829. printf("*************************************\n");
  830. break;
  831. }
  832. }
  833. if (lives == 0) {
  834. printf("You lose! The word was: %s\n\n", word);
  835. printf("*************************************\n");
  836. printf("Thank you for playing Guess the Word!\n");
  837. printf("*************************************\n");
  838. }
  839. }
  840. void B_show_time(void) {
  841. time_t current_time;
  842. struct tm *time_info;
  843. char time_string[9];
  844. time(&current_time);
  845. time_info = localtime(&current_time);
  846. strftime(time_string, sizeof(time_string), "%H:%M", time_info);
  847. printf("The current time is: %s\n", time_string);
  848. }
  849. void B_displayWelcomeMessage(void) {
  850. printf("\t\t------------------------------------------\n\n");
  851. printf("\t\t------------------------------------------\n\n");
  852. printf("\t\t Welcome to The EPIC GAME \n\n");
  853. printf("\t\t------------------------------------------\n");
  854. printf("\t\t------------------------------------------\n\n");
  855. }
  856. void B_sayhello(char name[]){
  857. printf("\t\t Hello %s \n\n", name);
  858. }
  859. void B_username(void) {
  860. char name[100] = {0};
  861. printf("\t\t Please create a fun Username \n");
  862. scanf("%s", name);
  863. B_sayhello(name);
  864. }
  865. void b_entertostart() {
  866. char enter;
  867. printf("\t\t Press 'any key' to begin \n");
  868. scanf(" %c", &enter);
  869. enter = toupper(enter);
  870. }
  871. void B_userinfo(void){
  872. char info[100] = {0};
  873. printf("\t\t How old are you?\n");
  874. scanf("%d", &info);
  875. printf("\t\t Nice!!!\n");
  876. }
  877. void B_displayGameInstructions() {
  878. printf("\t\t To start this game, here are the instructions:\n\n # Read each question carefully and select the best answer from the choices provided.\n # You will receive points for each correct answer, and the game will keep track of your progress.\n # At the end of the game, you will be shown your final score and will have the option to play again.\n # Have fun and good luck!\n\n\n");
  879. }
  880. int B_testround(void) {
  881. int score = 0;
  882. char answer[20];
  883. printf("Play a Test Round!\n");
  884. printf("The points you get in this round will be added to the other rounds.\n");
  885. printf("Question 1: What is the capital of Spain?\n");
  886. printf("Options: a.)Madrid b.)Barcelona c.)Valencia d.)Granada ");
  887. printf("Answer: ");
  888. scanf("%s", answer);
  889. if (strcmp(answer, "a") == 0) {
  890. printf("Correct!\n");
  891. score++;
  892. } else {
  893. printf("Incorrect. The answer is a.\n");
  894. }
  895. printf("Question 2: What is the smallest planet in our solar system?\n");
  896. printf("Options: a.)Earth b.)Mars c.)Mercury d.)Sun ");
  897. printf("Answer: ");
  898. scanf("%s", answer);
  899. if (strcmp(answer, "c") == 0) {
  900. printf("Correct!\n");
  901. score++;
  902. } else {
  903. printf("Incorrect. The answer is c.\n");
  904. }
  905. return score;
  906. }
  907. int B_round1(void) {
  908. int score = 0;
  909. char answer[20];
  910. printf("Round 1\n");
  911. printf("Question 1: What is the value of x in the equation 2x + 1 = 7?\n");
  912. printf("Hint: Subtract 1 from both sides and then divide both sides by 2.\n");
  913. printf("Options: a.)1 b.)2 c.)3 d.)4 ");
  914. printf("Answer: ");
  915. scanf("%s", answer);
  916. if (strcmp(answer, "c") == 0) {
  917. printf("Correct!\n");
  918. score++;
  919. } else {
  920. printf("Incorrect. The answer is c.\n");
  921. }
  922. printf("Question 2: What is the value of x in the equation 3x + 2 = 8?\n");
  923. printf("Hint: Subtract 2 from both sides and then divide both sides by 3.\n");
  924. printf("Options: a.)1 b.)2 c.)3 d.)4 ");
  925. printf("Answer: ");
  926. scanf("%s", answer);
  927. if (strcmp(answer, "b") == 0) {
  928. printf("Correct!\n");
  929. score++;
  930. } else {
  931. printf("Incorrect. The answer is b.\n");
  932. }
  933. return score;
  934. }
  935. int B_round2(void) {
  936. int score = 0;
  937. char answer[20];
  938. printf("Round 2 - True or False\n");
  939. printf("Question 1: The sun rises in the west.\n");
  940. printf("Options: a.)Ture b.)False");
  941. printf("Answer: ");
  942. scanf("%s", answer);
  943. if (strcmp(answer, "b") == 0) {
  944. printf("Correct!\n");
  945. score++;
  946. } else {
  947. printf("Incorrect. The answer is b.\n");
  948. }
  949. printf("Question 2: The capital city of France is known as the 'City of Love'.\n");
  950. printf("Options: a.)Ture b.)False");
  951. printf("Answer: ");
  952. scanf("%s", answer);
  953. if (strcmp(answer, "a") == 0) {
  954. printf("Correct!\n");
  955. score++;
  956. } else {
  957. printf("Incorrect. The answer is a.\n");
  958. }
  959. return score;
  960. }
  961. int B_round3(void) {
  962. int score = 0;
  963. char answer[20];
  964. printf("Round 3\n");
  965. printf("Question 1: How many planets are in our solar system?\n");
  966. printf("Options: a.)5 b.)6 c.)7 d.)8");
  967. printf("Answer: ");
  968. scanf("%s", answer);
  969. if (strcmp(answer, "d") == 0) {
  970. printf("Correct!\n");
  971. score++;
  972. } else {
  973. printf("Incorrect. The answer is d.\n");
  974. }
  975. printf("Question 2: How many bones are there in the human body? \n");
  976. printf("Options: a.)206 b.)205 c.)207 d.)204");
  977. printf("Answer: ");
  978. scanf("%s", answer);
  979. if (strcmp(answer, "a") == 0) {
  980. printf("Correct!\n");
  981. score++;
  982. } else {
  983. printf("Incorrect. The answer is a.\n");
  984. }
  985. return score;
  986. }
  987. int B_round4(void) {
  988. int score = 0;
  989. char answer[20];
  990. printf("Round 4\n");
  991. printf("Question 1: What is the capital of France?\n");
  992. printf("Options: a.)Paris b.)London c.)Madrid d.)Berlin");
  993. printf("Answer: ");
  994. scanf("%s", answer);
  995. if (strcmp(answer, "a") == 0) {
  996. printf("Correct!\n");
  997. score++;
  998. } else {
  999. printf("Incorrect. The answer is a.\n");
  1000. }
  1001. printf("Question 2: Who painted the Mona Lisa?\n");
  1002. printf("Options: a.)Leonardo da Vinci b.)Michelangelo c.)Raphael d.)Titian");
  1003. printf("Answer: ");
  1004. scanf("%s", answer);
  1005. if (strcmp(answer, "a") == 0) {
  1006. printf("Correct!\n");
  1007. score++;
  1008. } else {
  1009. printf("Incorrect. The answer is a.\n");
  1010. }
  1011. return score;
  1012. }
  1013. int B_round5(void) {
  1014. int score = 0;
  1015. char answer[20];
  1016. printf("Round 5\n");
  1017. printf("Question 1: Who invented the World Wide Web?\n");
  1018. printf("Options: a.)Bill Gates b.)Steve Jobs c.)Tim Berners-Lee d.)Mark Zuckerberg");
  1019. printf("Answer: ");
  1020. scanf("%s", answer);
  1021. if (strcmp(answer, "c") == 0) {
  1022. printf("Correct!\n");
  1023. score++;
  1024. } else {
  1025. printf("Incorrect. The answer is c.\n");
  1026. }
  1027. printf("Question 2: Who was the first person to walk on the Moon?\n");
  1028. printf("Options: a.)Neil Armstrong b.)Buzz Aldrin c.)Michael Collins d.)Pete Conrad");
  1029. printf("Answer: ");
  1030. scanf("%s", answer);
  1031. if (strcmp(answer, "a") == 0) {
  1032. printf("Correct!\n");
  1033. score++;
  1034. } else {
  1035. printf("Incorrect. The answer is a.\n");
  1036. }
  1037. return score;
  1038. }
  1039. void b_epic_game() {
  1040. B_displayWelcomeMessage();
  1041. b_entertostart();
  1042. B_username();
  1043. B_userinfo();
  1044. B_displayGameInstructions();
  1045. B_show_time();
  1046. int total_score = 0;
  1047. total_score += B_testround();
  1048. total_score += B_round1();
  1049. total_score += B_round2();
  1050. total_score += B_round3();
  1051. total_score += B_round4();
  1052. total_score += B_round5();
  1053. }
  1054. void feedbackForm(void){
  1055. int rating;
  1056. char feedback[1000];
  1057. printf("\nQuick Feedback Form:\n\n");
  1058. printf("On a scale of 1 to 5, how would you rate the quiz? (1 being poor and 5 being excellent): ");
  1059. scanf("%d", &rating);
  1060. getchar();
  1061. printf("Please provide any additional feedback: ");
  1062. fgets(feedback, sizeof(feedback), stdin);
  1063. printf("\nThank you for your feedback!\n");
  1064. printf("Your rating: %d/5\n", rating);
  1065. printf("Your feedback: %s\n", feedback);
  1066. }
  1067. void displayCredits(void) {
  1068. printf("*******************************\n");
  1069. printf("Thank you for playing our Game!\n");
  1070. printf("*******************************\n\n");
  1071. printf("This game was developed as a project for Hochschule Fulda. \nCreated by Vedant Bodhe, Emmanuel Afanyede, Berke Sevenler and Gabriel Tchakunte.\n\n");
  1072. printf("Special thanks to:\n");
  1073. printf("- Herr Thomas Papendieck (Lecturer: Programmiermethoden)\n");
  1074. printf("- Frau Monika Schak (Lecturer: Programming-1 in C)\n");
  1075. }
  1076. int main() {
  1077. int choice;
  1078. printf("Welcome to the Game Menu!\n");
  1079. printf("\t\t----------------------------\n\n");
  1080. printf("\t\t----------------------------\n\n");
  1081. printf("\t\t Welcome! \n\n");
  1082. printf("\t\t----------------------------\n");
  1083. printf("\t\t----------------------------\n\n");
  1084. printf("\t\tPress 'Enter' to join the Game \n");
  1085. char joinGame;
  1086. scanf("%c", &joinGame);
  1087. joinGame = toupper(joinGame);
  1088. if (joinGame != ' ') {
  1089. char vorName[100] ={0};
  1090. char nachName[100] ={0};
  1091. printf("\t\tPlease enter your First Name \n");
  1092. scanf("%s", vorName);
  1093. printf("\t\tPlease enter your Surname \n");
  1094. scanf("%s", nachName);
  1095. printf("\t\t------------------------------------------\n\n");
  1096. printf("\t\t------------------------------------------\n\n");
  1097. printf("\t\t Hello %s %s! \n\n", vorName, nachName);
  1098. printf("\t\t------------------------------------------\n\n");
  1099. printf("\t\t------------------------------------------\n\n");
  1100. printf("\n\nPlease choose one of the number options from below\n\n");
  1101. }
  1102. int jump_to_menu = 0;
  1103. while (choice != 8 || jump_to_menu) {
  1104. printf("Welcome to the Game Menu!\n");
  1105. printf("1. QuizGame\n");
  1106. printf("2. Fact or Lie?\n");
  1107. printf("3. Who wants to be a millionaire\n");
  1108. printf("4. Guess the Number!\n");
  1109. printf("5. Guess the Word!\n");
  1110. printf("6. Smart Brain\n");
  1111. printf("7. Epic Game\n");
  1112. printf("8. Exit\n");
  1113. printf("Enter your choice: ");
  1114. scanf("%d", &choice);
  1115. switch(choice) {
  1116. case 1:
  1117. play_quizgame();
  1118. jump_to_menu = 1;
  1119. break;
  1120. case 2:
  1121. play_factorlie();
  1122. jump_to_menu = 1;
  1123. break;
  1124. case 3:
  1125. play_milliongame();
  1126. jump_to_menu = 1;
  1127. break;
  1128. case 4:
  1129. play_guessingGame();
  1130. jump_to_menu = 1;
  1131. break;
  1132. case 5:
  1133. play_guessTheWord();
  1134. jump_to_menu = 1;
  1135. break;
  1136. case 6:
  1137. e_smart_brain();
  1138. jump_to_menu = 1;
  1139. break;
  1140. case 7:
  1141. b_epic_game();
  1142. jump_to_menu = 1;
  1143. break;
  1144. case 8:
  1145. printf("\nThank you for trying our C code!\n");
  1146. break;
  1147. default:
  1148. printf("Invalid choice!\n");
  1149. }
  1150. if (jump_to_menu) {
  1151. jump_to_menu = 0;
  1152. printf("\nType any key and press enter to jump back to the menu.\n");
  1153. char jump_key;
  1154. scanf(" %c", &jump_key);
  1155. jump_key = toupper(jump_key);
  1156. }
  1157. }
  1158. feedbackForm();
  1159. displayCredits();
  1160. return 0;
  1161. }