c17su99t1 - CSc 17 Test 1 1 Thursday 10 June...

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

CSc 17 Test 1 Thursday 10 June 1999 ###########ANSWERS#################### 1. (10 pts)Given the function definitions below, state what output is generated by the code below the dashed line. void b(int & x, int &y) {y++; x+=y; cout <<x<<" "<<y<<" "; } void a(int & x, int& y,int z) { x=y+z; y=y+z; b(x,z); cout << x << " " << y << " " << z<<endl; } ----------------------------------------------------------- int u=1,v=2,w=3; //9 4 9 5 4 a(u,v,w); //9 5 3 cout << u << " " << v << " " << w << endl; //8 8 w=3; b(w,w); 2. (10 pts) In the code below find 10 syntax errors and no more. I will only grade the first 10 syntax errors you identify. Note that I have not provide definitions for all the functions, but that will not generate a syntax error, rather, if the code compiles, it will generate a linker error, because the definition(s) cannot be found. #include <fstream.h> void func(int a, bool b) // MISSING ; int b(ifstream in) // MISSING ; // & NEEDED BEFORE in void main { // MISSING () AFTER main ifstream inF; b(inF); if(func(2,true)) // func DOES NOT RETURN ANYTHING cout<<"good"; cout<<" day"; else // MISPLACED else cout<<"bad day"; func(6); // TOO FEW ARGUMENTS TO func cout<<b(3); // BAD ARGUMENT TO b } int b(ifstream in){ // & NEEDED BEFORE in in>>a; // MISSING return } 3. (10 pts) What is the output when the following code is executed?
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • varies

{[ 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