c17f99t1 - CSc 17 Test 1 Monday 18 October 1999 Page 1...

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

View Full Document Right Arrow Icon
CSc 17 Test 1 Monday 18 October 1999 Page 1 >>>>>>>>>>>>>>>>>>SUGGEST ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (15 pts) Given that the function 'truth' is defined as char truth(bool t){ if(t) return 'T'; return 'F';} what is the output of the following lines of code? cout<<(2+3%4*5/6%7)<<endl; 4 cout<<(truth( (2>3 || 4<5) && (8==9 || 8!=9)))<<endl; T cout<<truth( truth(2>3) > truth(2<3) )<<endl; F cout<<(2+3%4*5.0/(6%7))<<endl; 4.5 cout<<(char('F'+14))<<endl; T 2. (15 pts)Given the function definition below, state what output is generated by the code below the dashed line. void q(int & x, int& y,int z) { x=x+2; y=y+3; z=z+1; x=z+2; cout << x << " " << y << " " << z<<endl; } ----------------------------------------------------------- int x,a,y; x=1; a=2; y=3; q(x,a,y); 6 5 4 cout << x << " " << a << " " << y << endl; 6 5 3 x=1; a=2; y=3; q(x,a,x); 4 5 2 cout << x << " " << a << " " << y << endl; 4 5 3 x=1; a=2; y=3; q(x,x,x); 4 4 2 3. (10 pts) I forgot to document the purpose of the following function. Provide the documentation. //Purpose: Determine whether two arrays are of the same size and have // identical entries //PreConditions: a and b are 0 or greater //PostConditions: The arrays are left unchanged bool quizzical(double x[],int a, double y [], int b){ if (a!=b) return false; for(int k=0; k<a; k++) if(x[k]!=y[k])
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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