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.


C
struct Calibration {
    int shift;
    int values[3];
};

struct Calibration live = {6, {4, 7, 2}};
struct Calibration saved = live;

live.values[1] += saved.values[0];
saved.shift -= 1;

if (live.values[1] > 10) {
    live.shift = saved.shift + live.values[2];
    saved.values[2] += live.shift;
} else {
    live.shift = 0;
}
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Data and Control Structures in C Questions: