CSC 17 Test 1 SPRING 1998

# CSC 17 Test 1 SPRING 1998 - CSc 17 Test 1 Thursday 12...

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

CSc 17 Test 1 Thursday 12 February 1998 Page 1 >>>>>>>>>>>>>>>>ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (15 pts) State the output generated by the following code: ( int(true) is 1, int(false) is 0; indicate blanks with little squares ) cout << (2+3/4)<<" "<< (2+3%4)<< "\n" << (2+3.0/4) << " " << (2.0+3/4)<<" " << int( (2<3) || (3<4) ) << " " << char('a'+2) << char('T'-'A'+'a'+2) << double( 't'-'p') << setw(4) <<'a'<<setw(5)<<"He" << int ( ((2<3)==(4>5)) == (3==6)) << int(!(2!=3)); >>>>>>>>>>>>>>> 2 5 >>>>>>>>>>>>>>> 2.75 2 1 0 0cv4 a He10 2. (10 pts) Given the function and variable declarations below, state what output is generated by the code below the dashed line. int a(int x, int y, int z) { if (x>0) if (y>0) return (y+x); else if (x>y) return (x*y); else return (x-y); if (x<0) if (y>0) return (y-x-1); else return z; return (x+y+z); } ----------------------------------------------------------------- int x=1,y=2,z=-3; cout << a(x,y,z) << " " <<a(z,z,z) << " " << a(0,x,y) << " "

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## CSC 17 Test 1 SPRING 1998 - CSc 17 Test 1 Thursday 12...

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

View Full Document
Ask a homework question - tutors are online