New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CS 12 Final Review

by: Avid Notetaker

CS 12 Final Review CS 012

Avid Notetaker
GPA 4.0

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

This got me an A on the CS 12 Final Exam. Definitely worth getting. This study guide will likely increase your performance on the final exam.
Intro: CS For Sci, Math & Engr II
Kris Miller
Test Prep (MCAT, SAT...)
CS 12, final exam, review, Study Guide
75 ?




Popular in Intro: CS For Sci, Math & Engr II

Popular in ComputerScienence

This 7 page Test Prep (MCAT, SAT...) was uploaded by Avid Notetaker on Friday April 1, 2016. The Test Prep (MCAT, SAT...) belongs to CS 012 at University of California Riverside taught by Kris Miller in Winter 2016. Since its upload, it has received 58 views. For similar materials see Intro: CS For Sci, Math & Engr II in ComputerScienence at University of California Riverside.

Similar to CS 012 at UCR


Reviews for CS 12 Final Review


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 04/01/16
Topics: Arrays, cstrings, IO streams, stringstream?, structs, classes, Object oriented, Pointers,  dynamic memory, list, inheritance, polymorphism, Rule of three, copy constructor,  assignment op, destructor, recursion,   (1.) What is the output of this programPOINTERS  1.   #include <iostream>  2.   using namespace std;  3.   int main()  4.   {  5.       int arr[] = {4, 5, 6, 7};  6.       int *p = (arr + 1);  7.       cout << *p;  8.       return 0;  9.   }  a)  4      b)  5      c)  6      d)  7    (2.) What is the output of this programPOINTERS  1.   #include <iostream>  2.   using namespace std;  3.   int main ()  4.   {  5.       int numbers[5];  6.       int * p;  7.       p = numbers;  *p = 10;  8.       p++;  *p = 20;  9.       p = &numbers[2];  *p = 30;  10.      p = numbers + 3;  *p = 40;  11.      p = numbers;  *(p + 4) = 50;  12.      for (int n = 0; n < 5; n++)  13.          cout << numbers[n] << ",";  14.      return 0;  15.  }  a)  10,20,30,40,50,      b)  1020304050      c)  compiler error      d)  runtime error      (3.) What is the output of this program? ​POINTERS   1. #include <iostream>  2.   using namespace std;  3.   int main()  4.   {  5.        int arr[] = {4, 5, 6, 7};  6.        int *p = (arr + 1);  7.        cout << *arr + 9;  8.        return 0;  9.   }  a) 12      b) 5      c) 13      d) error    (4.) What is the output of this program? ​ARRAYS  1.   #include <stdio.h>  2.    using namespace std;  3.    int main()  4.    {  5.        char str[5] = "ABC";  6.        cout << str[3];  7.        cout << str;  8.        return 0;  9.    }  a) ABC      b) ABCD      c) BC      d) None Mentioned    (5.) Write a push_back function for the list class we learned in class. LIST  a. Draw a diagram of a list that shows the process of push_back.  b. Write code that does what your diagram does.    (6.) Write the strcpy function for c­strings. C ​ STRINGS    (7.) What does it mean for a function to be pure virtual? ​ Inheritance/Polymorphism     a. What restrictions does it place on the class with it?   b. What about classes derived from it?     Use the following code for questions 8­10  class base {  public:  int val;  string type;  base(int a, string t) : val(a), type(t) {}  void display() {  cout<<type<<”: “<<val;  }   };    class derived : public base{  private:  double cost;  public:  derived(int a, string t, double d) : base(a, t) {  cost = d;  }      void display() {  base::display();  cout<<” “<<cost;  }  };    (8.) What is the output of the following?   int main(){  base b(10, “apple”);  derived d(20, “orange”, 2.50);  base * a[2];  a[0]=&b;  a[1]=&d;  for(int i = 0; i<2; i++){  a[i]­>display();  cout<<endl;  }  }  a) b) c) d)  10 apple Syntax Error 10 apple Runtime Error  20 orange  20 orange 2.50    (9.) What is the output of the following?  int main(){  base b(10, “apple”);  derived d(20, “orange”, 2.50);  b.display();  cout<<endl;  d.display();  }  a) b) c) d)  10 apple Syntax Error 10 apple Runtime Error  20 orange  20 orange 2.50    (10.) For 8 and 9 explain your answers? What is the difference between the two? What would  you need to change to make them both act correctly?    (11.) What does it mean for a class to be abstract?    (12.) What’s the difference between virtual and pure virtual?    (13.) What are the three types of streams?    (14.) On paper write a function str_len that will take a c­string and return its length, ie.  str_len(“hello”); should return 5 (do not count the null character).    (15.) What is the header for main you must use if you wish to accept command line arguments?    (16.) What is the difference between classes and structs?    (17.) How many implicit parameters are there in the function:  void MyClass::display(int num, string str) { …    (18.) How many constructors must you declare for your program to compile? How many  destructors?    (19.) What is the difference between a SegFault and Undefined behaviour? Give example code  that is one but not the other.    (20.) Give an example of a base class and a class that should inherit from it (for example: Lion  should inherit from Animal)    (21.) In the rule of three, what are the three things mentioned?    (22.) What makes a function recursive?    (23.) How many characters can c hold after the following declaration?  char c[] = “Hey World!”;  (24.) What is the longest string c can hold after the following declaration?  char c[70] = “Hey World!”;  (25.) Which of the following causes a syntax error?  a)in fin ar[5[];    b)in fin *ar[);    c)in fin ar[]5];    d)in fin **rr;    (26.) Name 4 c­string functions.    (27.) What are the three types of fields in a class?    (28.) What is the result of the following code?  char c[5] = “Hello”;    a. Syntax Error c. No Error  b. SegFault d. Undefined Behaviour    (29.) Is there a difference between an infinite loop, and infinite recursion? Explain.    (30.) What are the two parts every recursive function must have?   


Buy Material

Are you sure you want to buy this material for

75 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.