APS106H1 Midterm: APS106H1_20141_621398289314mid_2014_B_answers

86 views5 pages

Document Summary

Faculty of applied science and engineering. Aps106 midterm ii march 27, 2014. Do all work in this booklet. Do not remove the staple. Time allotted: 60 min. Page 1 of 5 c[i] = 0; for(j=0; j<4; j++) { c[i] += a[i][j]*b[j]; int i,j; for(i=0; i<2; i++) { Answer: 10 30 int temp; temp = x; x = y; y = *z; Answer: 4 8 16 4 int a=4, b=8, c=12, d=16; Fun(a, b, &c, &d); printf("%d %d %d %d", a, b, c, d); return 0; The program below is supposed to calculate the mean of the non- zero data values using the function: calculate_mean. Unfortunately, the code contains 4 errors. Identify error in code by circling. #include double calculate_mean (int [], int *); int main() { int data[]={43,55,65,0,0,64,0,54,0,57,45,53} double mean; int num; num = sizeof(data)/sizeof(int); Correct error circled to left missing ; A (double)sum sum += *ptr; counter++; ptr++; if(*ptr) { *n = counter; return sum/counter;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents