Tracking Calibration Changes Across a Function Call

A technician runs the following C code on two sensor readings stored in millivolts. Determine the values of sample_mV[0], sample_mV[1], and baseline_mV immediately after calibrate returns. Give each value in mV, to one decimal place.


C
void calibrate(double *sample, double offset_mV) {
    sample[0] -= offset_mV;
    sample[1] -= offset_mV;
    sample = sample + 1;
    *sample = 2.0 * *sample;
    offset_mV = 0.0;
}

void process_readings(void) {
    double sample_mV[2] = {8.4, 12.6};
    double baseline_mV = 1.2;
    calibrate(sample_mV, baseline_mV);
    /* Determine the three values here. */
}
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 Implementation of Algorithms Using C Questions: