A controller calculates a credit value using the following C code. Each table row is an independent execution: credits starts at 2, and mode has the value shown. Enter the final value of credits as an exact integer for every row.
int credits = 2; switch (mode) { case 1: credits += 3; case 2: credits *= 2; break; case 3: credits -= 1; default: credits += 4; }
Unlock full course notes by signing up
Selecting response times from an array
A diagnostic script selects response times that are exact multiples of 2 ms. Trace this C code and give the final count, total in milliseconds, and i. Enter all three as exact integers.
Tracing a skipped iteration
A test program adds numbered task weights but skips task 3. Complete the trace table with the value of sum after each iteration, including the skipped iteration. Enter exact integers.
Nested loops with two control transfers
A test scheduler skips job 2 in every run and stops each run at a changing job number. After this C code finishes, what is the value of processed? Enter an exact integer count of jobs.
Independent calibration records
A calibration program keeps a live record and a saved copy. The following C statements execute in the order shown. Determine the final values of live.shift, live.values[1] and saved.values[2]. Give all three answers as exact integers.