#include <stdio.h>
#include <string.h>
int main( ) {
char answer[ 50 ] ;
int score = 0 ;
printf ( "Welcome to the Football Quiz!\n " ) ; printf ( "You will be asked 3 questions. Each correct answer gives you 1 point.\n \n " ) ;
// Question 1
printf ( "Question 1: Who won the FIFA World Cup in 2018?\n " ) ; fgets ( answer
, sizeof ( answer
) , stdin
) ; answer
[ strcspn ( answer
, "\n " ) ] = 0 ; // Remove newline character
if ( strcasecmp( answer, "France" ) == 0 ) {
score++;
} else {
printf ( "Wrong! The correct answer is France.\n " ) ; }
// Question 2
printf ( "\n Question 2: Which player has won the most Ballon d'Or awards?\n " ) ; fgets ( answer
, sizeof ( answer
) , stdin
) ;
if ( strcasecmp( answer, "Lionel Messi" ) == 0 || strcasecmp( answer, "Messi" ) == 0 ) {
score++;
} else {
printf ( "Wrong! The correct answer is Lionel Messi.\n " ) ; }
// Question 3
printf ( "\n Question 3: What is the name of the stadium where Manchester United plays?\n " ) ; fgets ( answer
, sizeof ( answer
) , stdin
) ;
if ( strcasecmp( answer, "Old Trafford" ) == 0 ) {
score++;
} else {
printf ( "Wrong! The correct answer is Old Trafford.\n " ) ; }
// Final Score
printf ( "\n Your final score is: %d out of 3\n " , score
) ;
if ( score == 3 ) {
printf ( "Congratulations! You're a football expert!\n " ) ; } else if ( score == 2 ) {
printf ( "Well done! You know a lot about football.\n " ) ; } else if ( score == 1 ) {
printf ( "Good try! But you can improve your football knowledge.\n " ) ; } else {
printf ( "Better luck next time!\n " ) ; }
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKCkgewogICAgY2hhciBhbnN3ZXJbNTBdOwogICAgaW50IHNjb3JlID0gMDsKCiAgICBwcmludGYoIldlbGNvbWUgdG8gdGhlIEZvb3RiYWxsIFF1aXohXG4iKTsKICAgIHByaW50ZigiWW91IHdpbGwgYmUgYXNrZWQgMyBxdWVzdGlvbnMuIEVhY2ggY29ycmVjdCBhbnN3ZXI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