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

Info icon This preview shows pages 1–3. 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. bool v(int &a,int &b,int c) {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; bool t; a=2; b=3; t=v(a,b,5) out(t, a, b); <<<<< 6 3 a=2; b=3; t=v(b,a,8) && v(b,a,8); <<<<< 4 6 out(t, a, b); a=2; t=v(a,a,3*a); <<<<< 6 6 out(t, a, a); }
Image of page 1

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

View Full Document Right Arrow Icon
4. (18 pts) I forgot to document the following function. Provide it.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern