c17f97t1

# c17f97t1 - CSc 17 Test 1 1 Wednesday 8 October 1997...

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

CSc 17 Test 1 Wednesday 8 October 1997 ANSWERS 1. (15 pts) This is a true-false question. After each expression state whether the expression evaluates to true or to false. ( 3/2 == (2/3+1)) TRUE (('a'>'b') || ( ('b'-'a')>0 ) ) TRUE (('a'+int(true))>'a') TRUE ((3/2.0) == (2/3.0 + 1)) FALSE ((17%3+1) > (3%17)) FALSE ( ((2>3)==(3>2)) == ( (4-3>0)==(10<4) ) ) TRUE ('0' == int('0') ) TRUE ( 'T'-'t' + 'q'-'Q' >0) FALSE ('t'-'r'+true == 3) TRUE ( !(4==5) == !(7>5) ); FALSE 2. (10 pts) Given the function and variable declarations below, state what output is generated by the code below the dashed line void a(int &x,int &y,int z) { if (x==y) {if (x>z) x++; z++;} else {x++; y++;} cout << " "<< x <<" "<< y <<" "<< z; return; } ----------------------------------------------------------------- int x,y,z; x=4; y=3; z=5; a(x,y,z); 5 4 5 cout <<" "<< x << " " << z; 5 5 x=4; y=3; a(x,x,y); 5 5 4 cout <<" "<< x << " " << y; 5 3 3. (15 pts) Find 10 syntax errors in the following code: #include <iosteam.h> << iostream.h misspelled a(int b); int c << missing semi-colon main << missing parentheses {float d; cin << d; << cin does not understand if a(d,8) << missing parentheses << too many parameters d=-d << missing semi-colon cout << d;} << missing return int a(int b) {b=d; << d is inaccessible to a return;} << must return a value

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

View Full Document
4. (30 pts) Given the declaration int list[20],count
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern