Challenge: Write Code Using Select that Times Out

Learn to create a timeout by writing code that uses the select pattern.

We'll cover the following

Problem statement

Write a quiz that will time out after a time limit determined by you. The quiz will read the questions and answers from the CSV file. After the timer ends, the quiz should display the number of correct answers out of the total number of questions.

For example, within 30 seconds and out of 10 questions, if the user gives three correct and two incorrect answers, the final statement should look like this:

Correct: 3, Incorrect: 2, Total: 10

Follow these steps:

  • Create a struct that stores the question and answer.
  • Create a function that reads the CSV file.
  • Create a function that stores data in a struct array and reads from it.
  • Create a timer for the timeout using select.
  • Use loops to loop over the problems array, ask user input for each problem, and store results in variables.
  • Make sure the timeout occurs after the given time limit.
  • Create a file that contains questions and answers separated by a comma, and store it in the CSV file.

If you want to proceed without creating a struct, that will also work fine.

Code

Write your solution in the following code comments:

Get hands-on with 1200+ tech skills courses.