c17f00t1

c17f00t1 - CSc 17 Test 1 Wednesday 18 October 2000...

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

View Full Document Right Arrow Icon
CSc 17 Test 1 Wednesday 18 October 2000 >>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (12 pts) Assume the statement if(x<y) if(x<5) cout<<'D'; else if(x>77) cout<<'A'; else cout<<'B'; is preceded by one of the four pairs of statements below. State the output that occurs for each pair a) x=61; y=8; <no output> b) x=4; y=7; D c) x=50; y=60; B d) x=80; y=90; A 2. (8 pts) State the output of the following code. char *ch="Hello"; ch[2]='\0'; cout<<(2+4*5%6)<<endl; 4 cout<<(2+3/4/5.0)<<endl; 2 cout<<'A'<<endl; A else cout<<'B'<<endl; cout<<ch<<endl; He 3. (12 pts) State the output of the following main program. d=&c; e=&b; a++; b+=a; c+=b; cout<<a<<" "<<b<<" "<<c<<endl; } void main(){ int x,y,z, *tPt,*vPt; x=1;
Background image of page 1

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

View Full DocumentRight Arrow Icon
y=5; z=10; tPt=&y; vPt=&x; func(x,y,z,tPt,vPt); 2 7 17 cout<<x<<" "<<y<<" "<<z<<endl; 1 7 17 x=10; y=20; func(x,x,x,tPt,vPt); 11 42 42 cout<<x<<" "<<*tPt<<" "<<*vPt<<endl; 42 42 42 } 4. (25 pts) Write a recursive function, sum(), which computes the sum of the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

c17f00t1 - CSc 17 Test 1 Wednesday 18 October 2000...

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

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