Question: Instructions Pointers, malloc, free memory For this assignment, we shall exercise dynamic memory allocation using malloc and then free the memory after it has been

Instructions

Pointers, malloc, free memory

For this assignment, we shall exercise dynamic memory allocation using malloc and then free the memory after it has been utilized. We shall create a mathematics addition quiz which is expandable to as many questions as the user inputs.

Write a program that

1) Asks the user for number of questions in the quiz.

2) Generates a quiz which has as many questions as the user entered in (1) above.

3) Allocates memory dynamically for storing

a) the question (both the operands -> 5 + 6, 5 and 6 are the operands)

b) the answer.

c) The veracity (correct / incorrect)

4) Presents the score card.

5) Frees all dynamically allocated memory

Sample output

 Instructions Pointers, malloc, free memory For this assignment, we shall exercise

Addition Quiz Enter number of problems that you want to attempt: 5 95 + 81 = 76 72 + 91 = 163 50 + 17 = 67 97 + 14 = 111 90 + 29 = 05 Quiz Results Question 95 81 72 91 50 17 97 14 9029 Correct No Yes Yes Yes No Your Answer 163 67 Your score card is 3 / 5-) 60.00 %

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!