CSC 101 Final Review

Your page rank:

Total word count: 1929
Pages: 7

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

What is the output of the following loop?

count = 5;
cout << ‘St’;
do
{
cout << ‘o’;
count–;
}
while (count <= 5);

This is an infinite loop.

____ loops are called post-test loops.

do…while

Which of the following loops does not have an entry condition?

do…while loop

The ____ statement can be used to eliminate the use of certain bool variables in a loop.

break

What executes immediately after a continue statement in a while and do-while loop?

loop-continue test

When a continue statement is executed in a ____, the update statement always executes.

for loop

d.
do…while loop

The output of the statement:

cout << tolower(‘$’) << endl;

is ____.

‘$’

Assume the following.

static_cast<int>(‘a’) = 97
static_cast<int>(‘A’) = 65

The output of the statement:

cout << static_cast<int>(tolower(‘B’)) << endl; is ____.

98

The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.

14.0

Given the following function prototype: int test(float, char); which of the following statements is valid?

int u = test(5.0, ‘*’);

A variable listed in a function call is known as a(n) ____ parameter. A variable list in a header is known as a(n) ____ parameter.

actual; formal

Given the following function:

int next(int x)
{
return (x + 1);
}

what is the output of the following statement?

cout << next(next(5)) << endl;

7

Which statement below about prototypes and headers is true?

Prototypes end with a semicolon, but headers do not.

Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal?

cout << testAlpha(5, ‘A’, 2);

Which of the following function prototypes is valid?

int funcTest(int, int, float);

Given the following function:

int strange(int x, int y)
{
if (x &gt; y)
return x + y;
else
return x – y;
}

what is the output of the following statement?

cout &lt;&lt; strange(4, 5) &lt;&lt; endl;

-1

What value is returned by the following return statement?

int x = 5;

return x + 1;

6

Suppose that printHeading is a function without any parameters. Which of the following is a valid function heading?

void printHeading()

8 Which of the following is a legal C++ function definition?

void funcTest(int& u, double& v) { cout << u << " " << v << endl; }

8 . There are two types of ____ parameters: value parameters and reference parameters.

formal

8 Consider the following definition.

void funBbeta(int&amp; one, double two)
{

}

Based on this function definition, which of the following statements is valid?

one is a reference parameter and two is a value parameter.

8 Suppose that you are given the following function definition:

void printSomeThing(int x)
{
for (int i = 1; i &lt;= x, i++)
cout &lt;&lt; "# ";
cout &lt;&lt; endl;
}

What is the output of the following statements?

printSomeThing(1);
printSomeThing(2);
printSomeThing(3);

# # # # # #

When a function is called, the value of the ____ parameter is copied into the corresponding formal parameter.

actual

____ parameters are useful when you want to return more than one value from a function.

Reference

You can declare a(n) ____ parameter as a constant by using the keyword const.

reference

What is the output of the following program?

#include &lt;iostream&gt;
using namespace std;

void one(int x, int&amp; y);
void two(int&amp; s, int t);

int main()
{
int u = 1;
int v = 2;

one(u, v);
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
two(u, v);
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;

return 0;
}

void one(int x, int&amp; y)
{
int a;

a = x;
x = y;
y = a;
}

void two(int&amp; s, int t)
{
int b;

b = s – t;
s = t + b + 2;
t = 4 * b;
}

1 1 3 1

The ____ of an identifier refers to where in the program an identifier is accessible (visible).

scope

____ identifiers are not accessible outside of the function (block).

Local

What is the output of the following C++ code?

int alpha = 5;
int beta = 10;

alpha = alpha + 5;

{
int alpha = 20;
beta = beta + 5;
}

cout &lt;&lt; alpha &lt;&lt; " " &lt;&lt; beta &lt;&lt; endl;

10 15

In C++, the scope resolution operator is ____.

::

Memory for ____ variables remains allocated as long as the program executes.

global

____ a function refers to the creation of several functions with the same name.

Overloading

Suppose that you have the following declaration.

enum cars {FORD, GM, TOYOTA, HONDA};
cars domesticCars = FORD;

The statement:

domesticCars = static_cast&lt;cars&gt;(domesticCars + 1);

sets the value of domesticCars to ____.

GM

Consider the declaration:

enum sports {BASKETBALL, FOOTBALL, HOCKEY, BASEBALL, SOCCER};

which of the following statements is true?

FOOTBALL <= SOCCER

What is the output of the following code?

enum courses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS};
courses registered;
registered = ALGEBRA;
cout &lt;&lt; registered &lt;&lt; endl;

0

The scope of a namespace member is local to the ____.

namespace

Which of the following statements is used to simplify the accessing of all globalType namespace members?

using namespace globalType;

The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace ____.

std

Before using the data type string, the program must include the header file ____.

string

Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of str3 is "____".

str1 = "abc";
str2 = "xyz";
str3 = str1 + ‘-‘ + str2;

abc-xyz

Suppose str = "xyzw";. After the statement str[2] = ‘Y’; The value of str is "____".

xyYw

Suppose str = "ABCDEFGHI". The output of the statement

cout &lt;&lt; str.length() &lt;&lt; endl;

9

The length of the string "Hello There. " is ____.

13

11 Consider the following statements.

string str = "ABCDEFD";
string::size_type position;

After the statement position = str.find(‘D’); executes, the value of position is ____.

3

11 Considering the statement string str = "Gone with the wind";, the output of the statement cout &lt;&lt; str.find("the") &lt;&lt;

endl; is ____.

10

11 Consider the following statements.

string str1 = "ABCDEFGHIJKLM";
string str2;

After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".

BCDE

11 Consider the following statements.

string str1 = "Gone with the wind";
string str2;

After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____".

with

11 The ____ function is used to interchange the contents of two string variables.

swap

11 Which of the following statements declares alpha to be an array of 25 components of the type int?

int alpha[25];

Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta?

beta[0]

11 Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the

index of the array salesData?

0 through 999

11 Suppose that sales is an array of 50 components of type double. Which of the following correctly initializes the

array sales?

for (int j = 0; j <= 49; j++) sales[j] = 0.0;

12 Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the

elements of list?

for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl;

12 What is the output of the following C++ code?

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

for (j = 0; j &lt; 5; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;

0 5 10 15 20

12 What is the value of alpha[2] after the following code executes?

int alpha[5];
int j;

for (j = 0; j &lt; 5; j++)
alpha[j] = 2 * j + 1;

5

What is the output of the following C++ code?

int alpha[5] = {2, 4, 6, 8, 10};
int j;

for (j = 4; j &gt;= 0; j–)
cout &lt;&lt; alpha[j] &lt;&lt; " ";
cout &lt;&lt; endl;

10 8 6 4 2

12 Consider the following declaration int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this

statement?

int alpha[] = {3, 5, 7, 9, 11};

12 Consider the following declaration int alpha[3];. Which of the following input statements correctly inputs values

into alpha?

cin >> alpha[0] >> alpha[1] >> alpha[2];

12 In C++, the null character is represented as ____.

‘\0’

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

char name[8] = "William";

12 Consider the following declaration char str[15];. Which of the following statements stores "Blue Sky" into str?

strcpy(str, "Blue Sky");

12 Consider the following declaration.
char charArray[51];
char discard;

Assume that the input is:
Hello There!
How are you?

What is the value of discard after the following statements execute?

cin.get(charArray, 51);
cin.get(discard);

discard = ‘\n’

Consider the following statement: double alpha[10][5];. The number of components of alpha is ____.

50

Consider the statement int list[10][8];. Which of the following about list is true?

list has 10 rows and 8 columns.

13 Which of the following correctly declares and initializes alpha to be an array of four rows and three columns and the

component type is int?

int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

After the following statements execute, what are the contents of matrix?

int matrix[3][2];
int j, k;

for (j = 0; j &lt; 3; j++)
for (k = 0; k &lt; 2; k++)
matrix[j][k] = j + k;

0 1 1 2 2 3

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 fifth row of sale?

sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[4][j];

A collection of a fixed number of elements (called components) arranged in n dimensions (n&gt;=1), called a(n) ____.

n-dimensional array

The statement ____ creates the vector object vecList of size size.

vector<elemType> vecList(size);

The statement ____ returns the element at the position index in vector vecList.

vecList[index]

____ is a valid int value.

46259

Suppose that x is an int variable, ch is a char variable, and the input is:

276.

Choose the values after the following statement executes:

cin &gt;&gt; ch &gt;&gt; x;

ch = ‘2’, x = 76

Suppose that ch1 and ch2 are char variables and the input is:

WXYZ

What is the value of ch2 after the following statements execute?

cin &gt;&gt; ch1;
ch2 = cin.peek();
cin &gt;&gt; ch2;

X

In a ____ control structure, the computer executes particular statements depending on some condition(s).

selection

14 The standard header file for the abs(x)function is ____.

<cmath>

14 The output of the statement:

cout &lt;&lt; pow(2.0, pow(3.0, 1.0)) &lt;&lt; endl;

is ____.

8.0

14 Functions that do not have a return type are called ____ functions.

void

14 Which of the following is a legal C++ function definition?

void funcAlpha(int u, double& v) { cout <<u << " " << v << endl; }

14 Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for

loops sets the index of gamma out of bounds?

for (j = 0; j <= 50; j++) cout << gamma[j] << " ";

A function prototype is ____.

a declaration, but not a definition

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending