Question: Need to rewrite the program to randomize the question order WITHOUT LOOPS. Each time you run the program, the order will be different. Use srand

Need to rewrite the program to randomize the question order WITHOUT LOOPS. Each time you run the program, the order will be different. Use srand ( ) and rand ( ) functions and % ( mod) operator to get random number.

The number of permutions we can have when order is important is : n! / ( n - r)! = 3!/(3-3)! = 3!/0! = 3! = 3 x 2 x 1 = 6

Get a random number from 1 to 6. If the random number is 1, use the 1 of the 6 permutations. If the number is 2, use 1 of the 5 permutation and so on.

Need to rewrite the program to randomize the question order WITHOUT LOOPS.

#include #define QUESTION_1 {\ printf ("What is USA stands for "); printf ("1. United States of America "); \ printf ("2. United Stand Always "); printf ("3. United South Africa "); \ printf ( "4. United State Employees "); \ scanf ( "Chhu", &answer); \ if ( answer 1) I score++; #define QUESTION_2 {\ printf ( "Where is USA "); \ printf ("1. Above Canada "); printf ("2. Below Canada "); \ printf ("3. Below Mexico "); \ printf ( "4. Next to Texas "); \ scanf ( "Chu", &answer); \ if ( answer == 2) score++; } #define QUESTION_3 {\ printf ("Where is Canada "); printf ("1. Below USA "); printf ("2. Next to Australia "); printf ("3. Below Mexico "); printf ("4. Above USA "); scanf ( "Chhu", &answer); if ( answer == 4) score++; } int main ( { unsigned char score = 0; unsigned char answer; QUESTION 1; QUESTION 2; QUESTION 3; printf ("Thank you for completing the Quiz. Your score=%d ", score ); return 0; }

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!