c17f01t1 - CSc 17 Test 1 Wednesday 17 October 2001...

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

View Full Document Right Arrow Icon
CSc 17 Test 1 Wednesday 17 October 2001 ===================SUGGESTED ANSWERS MARKED WITH "<<<<" ==================== 1. (16 pts) Assume you have the function v() below (which I forgot to format): char v(int x, int y) {char ch; ch='C'; if(x<y) if(x>0) if(x<5) ch='D'; else {if(x>77) ch='A';} else ch='B'; return ch; } For each of the four lines of code below state the output. a) cout << v(3,8); <<<<< D b) cout << v(6,8); <<<<< C c) cout << v(80,90); <<<<< A d) cout << v(-6,7); <<<<< B 2. (16 pts) State the output of each of the following code fragments. a) cout<<(8/7+12*3/5%5); <<<<< 3 b) cout<<(8.0/6+12.0*(3/5%5)); <<<<< 1.3333 c) if((6>7||8<9)==(6>7&&9<8)) <<<<< 2 cout<<1; else if(6>7==false==true) cout<<2; else cout<<3; d) cout<<('E'-'A')<<char('F'-'A'+'a'+1); <<<<< 4g 3. (18 pts) State the output of the following main program. {a++; b=b+a; return a+b>3*c; } void out(bool t,int a, int b) {if(t) cout<<a<<" "<<b<<endl; else cout<<b<<" "<<a<<endl; } int main() { int a,b;
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2008 for the course CSE 17 taught by Professor Varies during the Spring '08 term at Lehigh University .

Page1 / 3

c17f01t1 - CSc 17 Test 1 Wednesday 17 October 2001...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online