[Assignment] Design a Quiz Application


Submit solution

Points: 10
Time limit: 0.5s
Memory limit: 3M

Author:
Problem type
Allowed languages
C

Problem Definition

Define the Data Structures:
  • Create a structure to represent a quiz question, including the question text, multiple-choice options (as an array), and the index of the correct answer.
  • Define a structure for storing user information, including name and score.
Load Questions from a File or Database:
  • Create a file that stores the quiz questions and their answers.
  • Write a function to read the questions from the file and store them in an array of question structures.
Present Questions to the User:
  • Write a loop that iterates through the array of questions.
  • Display each question to the user along with the multiple-choice options.
  • Prompt the user for their answer and validate it.
Check Answers and Calculate Score:
  • Compare the user's answer with the correct answer index for each question.
  • Increment the score if the user's answer is correct.
Save Points and Update Leaderboard:
  • Load the current leaderboard from a file into an array of user structures.
  • Prompt the user to enter their name.
  • Update the user's score in the array of user structures.
  • Sort the array based on scores in descending order to create a leaderboard.
  • Write the updated leaderboard back to the file.
Display the Final Score and Leaderboard:
  • Display the user's final score.
  • Display the leaderboard to the user.
  • By saving the points and leaderboard in a file, you can persist the data across multiple quiz sessions. You can use a simple text file format for storing the data.

Remember to handle file I/O operations properly, including error handling, opening and closing files, and validating file access permissions.

Good luck with your quiz application!


Comments

There are no comments at the moment.