CIT 225 Final

Ace your homework & exams now with Quizwiz!

false

Integration testing is the same as unit testing(true or false)

#include<fstream>; open and close file

Two changes that one must make to a program in order to use an external file are ___ and ___.

structures and classes

Two places in the language C++ where one will find } ; are ___ and ___.

true

Unit testing is done for each module(true or false)

dangling reference

We talked about two types of problems that deal with pointers. One type is garbage and the other type is ___.

O(N^3)

What is the order of the following code? Do not solve it. (1 pt) double product = 1.0; for (int i = 0; i < n; i++) for (int k = 0; k < n; k++) for (int m = 0; m < n; m++) product = product * i * k * m

cols needs to be sent not row, rows not declared, check other spelling and syntax can't put values in struct, semi-colon after struct, varray[0].a

What's wrong? a. void showValues (int nums[4] [ ]) { for(rows = 0; rows < 4; rows++) for (cols = 0; col<5: cols++) cout<< nums[rows] [cols]; } b. struct TwoVals { int a = 5; int b = 10; } int main() { TwoVals varray[10]; varray.a[0] = 1; varray[3] = varray[2]; return 0; }

true

When a variable is defined as a class object, that object has all the attributes and functions associated with it just by giving the object name. (true or false)

true

When an array is passed to a function, the function has access to the original array.(true or false)

constructor

When creating a stack class, instead of using Createstack, or use a ___ function

true

One should have another person test their module(true or false)

true

One should not dereference a NULL pointer(true or false)

22, 12, 42

#include <iostream> #include <string> using namespace std; void scramble(int i, int &j, int &k) { i = 17 + i; j = 34 + k; k = 51 - i; } int main() { int i = 8; int j = 12; int k = 16; scramble(j, k, i); cout << i << " " << j << " " << k << endl; System("pause"); return 0; }

void- can stand alone in call, returns none or multiple through parameter list nonvoid- returns one value, call must be part of another statement

2 differences between void and nonvoid

data hiding

A big advantage that a class object has over a structured variables is ___.

true

A class can have more than one constructor function(true or false)

true

A component of a structure can be another structure or an array, as well as a simple data type. (True or false)

true

A double dimensional array can be considered as an array of arrays (True or false)

true

A nonvoid module can return a structure through the module name (True or false)

true

A nonvoid module must return a value to the calling statement(true or false)

false

A pointer that has not been initialized is automatically set to NULL(t or f)

true

A pointer variable is used to contain a binary address. (true or false)

false

A postfix expression is the reverse of its equivalent prefix expression(true or false)

false

A pretest loop will always be executed at least once(True or false)

priority

A queue that has a queue in it in which the most important things are stored is called a ___ queue.

LIFO, FIFO

A stack uses the idea of ___. An example of where it is used is ___.

true

A template queue class allows one to create queues of different types(true or false)

one pass, no parenthesis

An advantage of prefix over infix is ___.

true

An algorithm should be language independent(true or false)

true

An array is a collection of like objects(true or false)

false

An array is always passed by value(true or false)

attributes, methods

An object consists of two parts. These two parts are ___ and ___.

true

Any mathematical operations that can be performed on regular C++ variables can be performed on structure members (True or false)

true

Black box testing is when the tester cannot see the code(true or false)

true

By default, if there are no public or private sections in a class definition, it will be private(true or false)

false

By default, things declared in the declaration section of a class are public (true or false)

false

C++ stores a double dimensional array column by column(True or false)

double *dbl_ptr;

Define a double pointer

int settings[3][4]={{12,24,32,48}, {-3,67,71,0}, {0,0,0,0}};

Define a two-dimensional array named settings large enough to hold the table of data below. Initialize the array with the values in the table. (2 pts) 12 24 32 48 -3 67 71 0 0 0 0 0

true

Dynamic data can be deallocated during program execution, but static data remains unti the block in which it was declared is done executing (true or false)

19

Evaluate the following postfix expression if possible. 3 4 + 5 2 - * 7 + 9 -

true

Every C++ program must have a module named main(true or false)

no negative sizes in array, should be less than 10, can't set arrays equal in one statement

Find the error(s), if there are any, in each of the following sections of code. (1 pt/each) a. int collection[-20]; b. int table[10]; for (int x = 0; x < 20; x++) { cout<<"Enter the next value: "; cin>> table[x]; } c. int array1[4], array2[4] = {3, 6, 9, 12}; array1 = array2;

v,n,v,v,v,n

For each of the following, indicate whether one should use a void module (V) or a nonvoid (N) to solve the problem. (1/2 pt each) 1. __ A module that explains how one would play a game. 2. __ A module that will receive two numbers and returns the smaller of the two numbers. 3. __ A module that will receive the radius of a circle and return to the caller the area and the circumference of the circle. 4. __ A module that will return the total cost of a purchase, given the price of an item, how many items purchased and the tax rate in the given area. 5. __ A module that receives two items and returns the results of the two items switched. 6. __ A module that will return the number of yards when the number of inches is sent to the module.

Ptr=&num; Ptr=new int;

Given int num, *Ptr; show two different ways to give Ptr a value

9,3

Given the following array of numbers, how many comparisons will be needed before the value 99 is located using: (2 pts) a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9] -23 0 10 27 39 56 68 77 99 121 1. The linear search = _______ 2. The binary search = _______

true

Given the following header: void showArray(const int array[ ] [COLS], int rows) if COLS is a global named constant which is set to 4, then the function can accept any two dimensional integer array, as long as it consists of four columns. (True or false)

900, 580

Given the following, determine the address for each of the following: (show all work!!!!!!!!!) int List[30]; where the base address is 800 and each integer uses 4 bytes. double score[15]; where the base address is 500 and each double uses 8 bytes. 1. List [25] 2. score [10]

false

Global variables should be used whenever possible(true or false)

false

If a program compiles with no errors, then it will run with no errors(true or false)

true

If one initializes part of an array during declaration, the values of the uninitialized part of the array depend on whether the array was declared in the main or made global(True or false)

false

If one needs a parameter to be an in-out parameter, then that parameter should be passed by value(true or false)

true

If one opens a file to write to, then the original information in the file will be lost (True or false)

fstream

If one wants to use an external file, then they must include ___.

accessor

In a class, modules that retrieve the contents of the attributes, but do not change their values are called ___ modules.

false

It is possible to output the contents of all members of a structure variable using a cout << statement followed by the name of the structure variable (True or False)

Define the problem, create an algorithm, test by hand, convert to language of choice, test on computer using data from step 3, use and maintain

List the six steps involved in problem solving (according to me)

false

One can cin pointers(t or f)

false

One can directly access the private elements of a class in any program(true or false)

true

One can initialize all the elements in a double dimension during the declaration statement (True or False)

true

One can initialize all the memory locations of an array when the array is declared(true or false)

false

One can set one stack equal to another stack, by simply setting the one stack variable equal to the other stack variable(t or f)

true

One can set one structure equal to the contents of another structure of the same type in a single assignment statement(True or False)

Alist<float> ans;

One has declared a template class called Alist. Show how one would declare an object of Alist that is of type float.

data hiding

One of the strengths of using classes is ___.

false

Our C++ compiler allows one to access memory outside of an array range without signaling an error(true or false)

FIFO, print queues

Queues follow the principle of ___. One of its computer uses is ___.

::

Scope resolution symbol

num = 0 - initialize, while- test, cout- execute, last line- modify

Show the four parts of a loop using the loop below and show the output. ( 4 pts) num = 0; while (num < 10) { cout<<num << endl; num = num + 2; }

dynamic

Storage that may be obtained during the run of the program is called ___.

true

The amount of memory used by an array depends upon the array's data type and the numbers elements in the array. (True of False)

true

The base address of an array is associated with the name of the array(true or false)

true

The constructor module is neither a void module or a nonvoid module (true or false)

false

The designer of a module is responsible to make sure that the preconditions are met(true or false)

true

The module isStackfull is used if one uses an array implementation for the stack (true or false)

NULL

The one value that every pointer can be set equal to is ___.

true

The order of the operands determines if an equation is in infix, prefix or postfix form (t or f)

true

The purpose of using #ifndef and #endif when creating a class is to make sure that code that might be copied(True or false)

true

The scope resolution operator tells the compiler that the function is a member function of a particular class. (t or f)

false

The statement int scores[ ] = { 1, 2, 3, 4 }; is invalid because the size has not been declared(true or false)

nodes, edges

The two parts of a computer graph are ___ and ___.

(rear + 1) % n ==front; front==rear;

To determine if a static circular queue with a buffer is full, the test is ___. To determine if it is empty the test is ___.

top==n-1; top==-1;

To determine if a static stack is full, the test is ___. To determine if it is empty the test is ___.

new, delete

To get memory during run time, one must use the ___ command. To get rid of memory during run time, use the ___ command.

address

To pass an array to a function, pass the ___ of the array.

const

To prevent an array parameter from being changed in a module, one should put ___ before the array declaration.

class.h, .h, class.cpp, main.cpp

When dealing with nontemplate classes, in which file would the following be located? 1. Inline functions 2. endif 3. :: 4. rectangle object1;

sink hole

When no route in adjacency matrix

true

When one creates a class using templates, then the definition and implementations are all put in the .h file.

in the same directory

When one is using an external file for input, make sure that the file is located___.

row, column

When referencing a two-dimensional array, one must give the index of the ___ first, followed by the index of the ___.

actual

When using a template function, the actual type of the parameters is determined by the ___ parameters.

accessor

When using classes, a module (method) that does not change the attributes of an object of the class, is called a ___ module

true

When you pass by value, the actual parameters need to evaluate to actual values(true or false)

*

Which symbol is used to deference a pointer variable?

see path with 2 edges

Why would one multiply an adjacency matrix by itself?

for(int num=0; num < 10; x+2) cout<<num<<endl;

Write as for loop num = 0; while (num < 10) { cout<<num << endl; num = num + 2; }

true

You cannot use the assignment operator to copy one non character array's contents to another in a single statement(true or false)

syntax, driver, 120, subscript, const, search, small, large sorted, system("pause"); O(n^8), psuedocode, flowchart, one, green, addition, 6, actual, formal, parameter, return statement, index, parallel, 0, name, date, pretest, 0-24, work done, address of first location,

a. Misspelling the name of a variable in a C++ program is an example of a ___ error b. If one wants to test their module and the main has not been created, one can test their module by using a dummy main which is called a ___. c. If there are 120 elements in a sorted list, the maximum number of comparisons that will be needed for the linear search is ___. d.To access an array element, use the array name and the element's ___. e. If one wants to guarantee that an array location is not modified in a module, one should put ___ before the array declaration in the formal parameter list. An example of a module where this might be done is ___. f. One should use a linear search with ___ lists and a binary search with ___ lists. g. To make sure that the output of a program does not close quickly in our C++ compiler, one needs to insert the command ___ before the return 0; statement. h.The order of an algorithm that evaluates to 6x^8 - 25x^9 - 1000 is ___. i.Two ways to represent an algorithm are ___ and ___. j. Ideally, a module should have ___ job to do. k.In our compiler, comments are indicated by the color ___. l.The work done in an algorithm that finds the average of the elements in an array is ___. m.Given: int List[ ] = { -2, -1, 12, 34, -100, 42, 68}; what is the location of 68 in the array? n.The parameter list associated with the caller is called the ___ parameter list and that associated with the module itself is called the ___ parameter list. o. Two ways in which a module might return a value back to the caller are ___ and_____ p. By using the same ___, you can build relationships between data stored in two or more arrays of different types. This is an example of the use of ___ arrays. q. If an array is partially initialized, the uninitialized elements will be set to ___. r. Two things found in the prologue of a program are ___ and ___. s. The while loop and the for loop are examples of ___ loops. t. Given: char name[25]; what is the valid range for the subscripts? u. When comparing algorithms, the only thing that remains constant from one algorithm to another is ___. v. When one passes an array name as an argument to a function, one is actually passing the ___ of the array.

false

double *Pt1, *Pt2; and double* Pt1, Pt2; produce the same variable types(true or false)


Related study sets

Semistructured and Structured Interviews - Ch.3

View Set

Practice Exam 1 - Part 1 - Question 1 - 30

View Set

Studies in Leadership Final Exam

View Set

Physical Fitness: Unit 5: QUIZ 1: MOTIVATION AND MINDSET; QUIZ 2: DEALING WITH SETBACKS; QUIZ 3: STAYING MOTIVATED

View Set

Preethi's CBSE Class 10 Geography - Agriculture Part 1

View Set