Final review

Final review - FinalExamReview From36pm int c int bar cfw...

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

View Full Document Right Arrow Icon
Final Exam Review The Final is THIS Saturday From 3-6pm Check the CS31 website for details on where to go!
Background image of page 1

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

View Full Document Right Arrow Icon
What Does This Program Print? int c; int bar() { static int x = 0; return(x++); } main() { int a=0,b=1,c=2; c++; cout << a << b << c; if (a++ > 1 || ++c == bar()) cout << "whew!"; cout << a << b << c; }
Background image of page 2
Scrambles A word scramble is a puzzle in which the letters of a word are mixed in a different order. Here are some examples of scrambles: MISSISSIPPI -> PIPISSSSIMI UCLA -> ACLU Each scramble contains exactly the same letters as the original word, but in a different order. No letters are inserted or removed. Write a function called is_scramble that accepts two uppercase C++ strings as parameters. Your function should return true if the two strings are scrambles and false otherwise. main() { string a = “HELLO”, b = “ELHLO”; if (is_scramble(a,b)) cout << “Got one”;
Background image of page 3

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

View Full Document Right Arrow Icon
Cons and Dests What will the following program print  out? class Carey { public: Carey(string lastName = “Nacho”) { ln = lastName; cout << “Carey “<<ln<<“ is born\n”; } ~Carey() { cout << “Carey “<<ln<<“ dies\n”; } private: string ln; }; Carey a(“Grant”); void blah(void) { Carey c; } int main(void) { Carey arr[3]; Carey *ptr; ptr = new Carey(“Mariah”); for (int i=0;i<2;i++) { static Carey b(“Airy”); blah(); } delete ptr; }
Background image of page 4
New or Used Convert the following program to use  new and delete for  EVERY  variable. class Cubes { public: Cubes(void) { for (int i=0;i<10;i++) arr[i] = i*i*i; } int GetNthCube(int num) const { return(arr[num]); } private: int arr[10]; }; int main(void) { Cubes a; cout << a.GetNthCube(5); }
Background image of page 5

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

View Full Document Right Arrow Icon
Struct Challenges Write a function called printCars  that prints out the following  information for each car in array  arr :
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 15

Final review - FinalExamReview From36pm int c int bar cfw...

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

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