Midterm_solution

Midterm_solution - 1 Midterm Examination ENGR 3 August 29,...

This preview shows pages 1–3. Sign up to view the full content.

Midterm Examination Name:__________________ ENGR 3 Score:_____out of 100 points August 29, 2006 Brendon Hall Antonio Medrano Instructions: This is a closed book, closed notes examination. Try to confine your answers to the space provided. Where a problem asks you to write some C code, some credit will be given for explanatory comments in the absence of correct syntax. 1. (10 points) What is printed by the following code? int a=5, b=2, c=5, d=2; printf( “%d\n”, a+c/b+d ); 9 printf( “%d\n”, a*c/b+d ); 14 printf( “%.2f\n”, (float)(a+d)/d ); 3.50 printf( “%.2f\n”, (float)( (a+d)/d ) ); 3.00 2. (10 points) Give the value of the variables j and k after each statement is executed. Assume that just before each statement we have initialized the variables to their original values. int j, k; j = 8; k = 3; a) k = --j; k = ____ 7 ___ j = ____ 7 ___ b) k = j++; k = ____ 8 ___ j = ____ 9 ___ c) k += (j+2); k = ____ 13 __ d) k %= (k+2); k = ____ 3 ___ e) k = j/k; k = ____ 2 ___ 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. (6 points) Write a statement with a
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/06/2010 for the course ENGR 3 taught by Professor Ben-yaakov during the Summer '08 term at UCSB.

Page1 / 6

Midterm_solution - 1 Midterm Examination ENGR 3 August 29,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online