Modify the quiz program (page 508) so that the choices for a question are randomly arranged.

What will be an ideal response?


Replace the line subjects=($(ls)) in the function choose_subj with
scramble_subj and add the following functions:
function exchange_subj ()
{
temp_value=${subjects[$1]}
subjects[$1]=${subjects[$2]}
subjects[$2]=$temp_value
}
#==================
function scramble_subj ()
{
declare -i index subjcount
subjects=($(ls))
subjcount=${#subjects}
# Number of elements
((index=subjcount-1))
while [[ $index > 0 ]]; do
((target=RANDOM % index))
exchange_subj $target $index
((index -= 1))
done
}
#==================

Computer Science & Information Technology

You might also like to view...

The member access operator is which of the following

a) * b) % c) . d) /

Computer Science & Information Technology

Excel assigns date number 1 to January 1, 1900

Indicate whether the statement is true or false

Computer Science & Information Technology

What is the generally acceptedfive-phase model in the design process?

What will be an ideal response?

Computer Science & Information Technology

One of the goals of business intelligence is to _________.

A. ?present the results in an easy to understand manner B. educate the users about business statistics C. ensure the transaction data is properly stored D. use the most sophisticated techniques

Computer Science & Information Technology