C s150
Download
1 / 28

c s150 - PowerPoint PPT Presentation


  • 415 Views
  • Uploaded on

c s150. Tuesday, April 15 th. 8 - arrays. Exam 2 – next Tuesday , You will need a blue scantron . 8 - arrays 9 - structs 10 - classes 12 - pointers 14 - exceptions 16 - searching/sorting/vectors - linked lists Exam 2, go over the solution – next Thurs .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' c s150' - judith


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
C s150

cs150

Tuesday, April 15th


8 arrays
8 - arrays


Exam 2 – next Tuesday,

You will need a blue scantron.

8 - arrays

9 - structs

10 - classes

12 - pointers

14 - exceptions

16 - searching/sorting/vectors

- linked lists

Exam 2, go over the solution – next Thurs


Given the following declaration:

int j;

int sum;

double sale[10][7];

which of the following correctly finds the sum of the elements of the fourth column of sale?

a. sum = 0;

for (j = 0; j < 7; j++)

sum = sum + sale[j][3];

b. sum = 0;

for (j = 0; j < 7; j++)

sum = sum + sale[j][4];

c. sum = 0;

for (j = 0; j < 10; j++)

sum = sum + sale[j][4];

d. sum = 0;

for (j = 0; j < 10; j++)

sum = sum + sale[j][3];


A collection of a fixed number of elements (called components) arranged in n dimensions (n>=1) is called a(n) ____.

a. matrix c. n-dimensional array

b. vector d. parallel array


In row order form, the ____. components) arranged in

a. first row is stored first c. first column is stored first

b. first row is stored last d. first column is stored last


Consider the following statement: components) arranged in

double alpha[5][10];.

The number of components of alpha is ____.

a. 15 c. 100

b. 50 d. 150


Consider the following declaration: components) arranged in

char str[15];

Which of the following statements stores "Blue Sky" into str?

a. str= "Blue Sky";

b. str[15] = "Blue Sky";

c. strcpy(str, "Blue Sky");

strcpy("Blue Sky");


Which of the following correctly declares name to be a character array and stores "William" in it?

a. char name[6] = "William";

b. char name[7] = "William";

c. char name[8] = "William";

d. char name[8] = 'William';


All components of an array are of the same data type. character array and stores "William" in it?

The array index can be any integer less than the array size.

The statement int list[25];

declares list to be an array of 26 components, since the array index starts at 0.

Given the declaration int list[20];

the statement

list[12] = list[5] + list[7];

updates the content of the twelfth component of the array list.

If an array index goes out of bounds, the program always terminates in an error.


Suppose list is a one dimensional array of size 25, wherein each component is of type int. Further, suppose that sum is an int variable. The following for loop correctly finds the sum of the elements of list.

sum = 0;

for (int i = 0; i < 25; i++)

sum = sum + list;


What statement each component is of type int. Further, suppose that sum is an declares alpha to be an array of 25 components of the type int?

a.intalpha[25]; c.intalpha[2][5];

b.int array alpha[25]; d.int array alpha[25][25];


What is the output of the following C++ code? each component is of type int. Further, suppose that sum is an

int list[5] = {0, 5, 10, 15, 20};

int j;

for (j = 0; j < 5; j++)

cout << list[j] << " ";

cout << endl;


9 classes
9 each component is of type int. Further, suppose that sum is an - classes


A class is an example of a structured data type. each component is of type int. Further, suppose that sum is an

In C++ terminology, a class object is the same as a class instance.

The public members of a class must be declared before the private members.

As parameters to a function, class objects can be passed by reference only.


The components of a class are called the ____ of the class each component is of type int. Further, suppose that sum is an .

a. elements c. objects

b. members d. properties


Is each component is of type int. Further, suppose that sum is an the following class definition correct in C++?

class studentType

{

public void setData(string, double, int);

private string name;

};


Is each component is of type int. Further, suppose that sum is an the following class definition correct in C++?

class studentType

{

public:

void setData(string, double, int);

void print() const;

private:

string name;

double gpa;

}


Is each component is of type int. Further, suppose that sum is an the following class definition correct in C++?

class studentType

{

public:

void setData(string, double, int);

private:

string name;

};


If a member of a class is ____, you cannot access it outside the class.

a. public c. private

b. automatic d. static

A class and its members can be described graphically using a notation known as the ____ notation.

a. OON c. UML

b. OOD d. OOP


The word ____ at the end of the member functions in the the class.above class clockTypespecifies that these functions cannot modify the member variables of a clockType object.

a. static c. automatic

b. const d. private


What is the class.the name of the class?

How many private members are in the class?

What indicates private members in the class?

What indicates public members in the class?

What indicates protected members in the class?



A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block.

a. static c. local

b. automatic d. public


A class object can be ____. That is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates.

a. static c. local

b. automatic d. public

In C++, you can pass a variable by reference and still prevent the function from changing its value by using the keyword ____ in the formal parameter declaration.

a. automatic c. static

b. private d. const


Which when the control reaches its declaration, and destroyed when the program terminates of the followingis the correct prototype for a templatefunction (from lecture).

template-class <functionT>

T maxThree(T x, T y, T z);

template <class T>

T maxThree(T x, T y, T z);

class <templateT>

T maxThree(T x, T y, T z);


More on Thursday when the control reaches its declaration, and destroyed when the program terminates

Questions?