{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

08 lecture (midterm 2 review)

08 lecture (midterm 2 review) - 2 write the complete...

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

View Full Document Right Arrow Icon
5/16/08 Midterm 2 Chapter 5: -be able to write or analyze/find errors in functions -know the difference between value parameters and reference parameters (***look up passing reference parameters) - return valves/return types -function calls Chapter 6: -Be able to write or analyze/find errors in class code (or code that uses functionality of a class) -constructors/member functions/ dot-notation -data field access -implicit parameters vs. explicit parameters Chapter 7: - understand for and do and while loops - understand loops within loops (nested combinations) -section 7.8 on processing input -section 7.9 on simulation Chapter 9: -understand vectors and how to use them in functions and class codes -know how to write and analyze/find errors in code involving vectors -push_back, pop_back, and size practice quiz: 1)write the output of the code below: int func2 (int & c) { c = 2; return c; } int func1 (int b) { func2 (b); return b; }
Image of page 1

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

View Full Document Right Arrow Icon
int main() { int a = 1; int b = func1 (a); cout<< a << " " << b << "\n"; return 0; } //this code would output "1 2"
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2) write the complete student class ( 2 fields, one int and one string). include defalt and regular constructor. include and accessor in each field. Class Student { public: Student ( ); Student (int a, string b); string get_name () const; int get_score () const; private: int score; string name; }; Student:: Student () { name = " "; score = 0; } Student:: Student( int a, string b) { score = a; name = b; } 3) write the output int main() { vector <int> z(6); z[0] = 23; z[1] = 77; z[2] = 41; z[3] = 98; z[4] = 46 ; z[5] = 62; for (int i = 5; i>0; i-2) { z.pushback (z [ i ] ); } z.pop_back( z [ i ] ); cout << z[ z.size( )-1 ] << "\n"; return 0; } this code outputs 98. first it adds 77, then gets rid of it and then outputs the last number of the set. 4) write dow every combination of the statements that can execute int main() { if (condition 1) statement 1 if (condition 2) statement 2 else statement 3 return 0; } //the possible combinations would be:-1 and 2-1 and 3-2-3...
View Full 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