0% found this document useful (0 votes)
31 views

Visual C++ Programming Final

Uploaded by

palesa902
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Visual C++ Programming Final

Uploaded by

palesa902
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

CSC 2265 Visual C++ Programming Final

Study online at https://quizlet.com/_6ija9d


The rand function returns an integer that is greater than or equal
RAND_MAX
0 but less than or equal to the value stored in which constant?
In a pretest loop, what initializes the loop condition by providing its
priming read
first value?
Unless you specify otherwise, variables in C++ are automatically
value
passed by which method?
3 How many arguments can the for clause contain?
What is the result of the following code?

int xNum = 0;

int yNum = 0;

do
xNum: 0 is printed
{

xNum = xNum + yNum;

yNum += 1;

cout << "xNum: " << xNum;

} while (xNum > 2);


If you want to send the value contained in a variable to a function,
passing by value
which method should you use?
When a counter is incremented or decremented, what process is
updating
occurring to the variable?
What type of functions allow large and complex programs to be
Program-defined
broken into small and manageable tasks?
counter What is used to terminate a counter-controlled loop?
What is the correct order of the possible arguments in a for
initialization, condition, update
statement?
In a repetition structure, what is the requirement for repeating the
looping condition instructions called?
Select one:
What type of loop is often used in programs that allow the user to
posttest
select from a menu?
bottom-driven loop A posttest loop is also referred to as which of the following?
What is wrong with the following code?

int xNum, yNum;


do
yNum should be initialized
for (xNum = 1; xNum < 10; xNum += 1)
yNum += 2;
while (yNum < 20);

1/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
What is the output of the following code?

int xNum = 0;

int yNum = 0;

do
3
{

xNum += yNum;

} while (xNum == yNum++);

cout << xNum;


What is the result of the following code?

int xNum, yNum, zNum;

yNum = 0;

zNum = 0;
endless loop
do

for (xNum = 1; xNum < yNum; yNum += 1)

zNum += xNum;

} while (zNum < 100);

cout << "zNum: " << zNum;


How many times will the instruction in the loop body of the follow-
ing code be processed?

int x = 0;

2 do

x += 3;

} while (x <= 3);


condition In a for statement, which argument or arguments are required?
The function header for a value-returning function begins with
the returnDataType
which of the following?
In a repetition structure, what is the requirement for not repeating
loop exit condition
the instructions called?

2/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
In the following code, what is the scope and lifetime of the num1
variable?

int num2 = 100;

int main()

local, until the for loop ends

for (int num1=1; num1 < num2; num1+=1)

............. more code here ...........

}
What statement is required in the function getSquarePerimeter to
assign a value to the variable p in the following statement?
return

p = getSquarePerimeter(side);
What property of a variable indicates where in the program the
scope
variable an be used?
A loop whose instructions are processed indefinitely is referred to
infinite loop
as which of the following?
base number and exponent What is (are) the argument(s) passed to the pow function?
to the operating system Where does the main function return its value?
double What is the data type of the value returned by the sqrt function?
for, while Which two C++ statements can be used to code pretest loops?
while What statement can be used to code a pretest loop in C++?
What type of structure allows you to repeat a set of instructions
loop
multiple times?
What is assigned to the answer variable after the following code
is executed?

int answer = 0;

int yNum = 0;

do
0
{

for (int xNum = 1; xNum < 3; xNum +=1)

answer = answer * xNum;

yNum += 1;

} while (yNum < 3);


Boolean The condition in a while loop must evaluate to what type of value?

3/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
press Ctrl+c What can you do to stop an endless loop in a C++ program?
Which #include directive may you need in your program in order
<cstdlib>
to use the random number generator functions?
What is wrong, if anything, with the following code?

double price = 0;

cout << "Item price: ";

cin >> price;


missing the update read
do

cout << "Total cost: $" << price + price * .05 << endl;

cout << "Item price: ";

} while (price > 0);


Which #include directive must be in a program that uses the sqrt
<cmath>
function?
Which character is used to separate each clause in a for state-
semicolon
ment?
What type of loop statement should you use if the instructions in
do while
the loop body must be processed at least once?
How many values does a value-returning function return at its
one
completion?
What type of variable is used for adding together a series of
accumulator
values?
They are declared outside of any functions Which of the following is true about global variables?
Although not required, it is good programming practice to mark the
comment
end of the loop with a(n) _____.
How many times will the instruction in the loop body of the follow-
ing code be processed?

int x = 3;

2 do

x++;

} while (x <= 3);


In the code below, what is the scope of the num1 variable?

int num1;

global int main()

cin >> num1;

4/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
cout << num1 *.10;

... more code here ...

}
constant What type of value is used to update a counter?
What is the output of the following code?

int xNum = 0;

int yNum = 0;

do
12
{

for(yNum = 0; yNum < 3; yNum += 1)

xNum += yNum;

} while (xNum < 10);

cout << xNum;


Which of the following is a valid invocation of a value-returning
x = myFunction(y, z);
function?
What is the proper function type to use when declaring a function
void that takes two floating point numbers and calculates and displays
the product with no return value?
What is the correct statement needed to call a void function named
sumIt(&totalSum);
sumIt that changes the value of the variable named totalSum?
void What keyword begins the function header of a void function?
The arguments that are passed to a function are referred to as
actual arguments
which of the following?
invoke Which of the following is another term for calling a function?
What type of functions do not return a value after completing their
void
task?
What, if anything is required to fix the following code?

char val1, val2;

val1 = 10;

val2 = 25;

printSum(val1, val2);
val1 and val2 are the wrong type

void printSum(int x, int y)

cout << "The sum is: " << x + y << endl;

}
5/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
& Which symbol is used to represent the address-of operator?
Which of the following is true about the relationship between the
their names can be different
actual parameter and the corresponding formal parameter?
local to the function What is the scope of the variables listed in a function?
Sending a copy of a variable's value to a function is referred to as
passing by value
which of the following?
To pass a variable by reference in C++, what must be included
& before the name of the corresponding formal parameter in the
receiving function's header?
If you want a function to know the contents of a variable, but don't
by value want the function to modify the value, in what manner should the
variable be passed?
The function body in a void function is enclosed in which of the
braces
following?
function header What is the first part to the function definition of a void function?
Unless you specify otherwise, in what manner are variables
by value
passed to functions?
Which of the following is a proper declaration of a function that
void printSum(int val1, int val2)
sums and displays two integers and returns no value?
If you want a function to modify the value stored in a variable, how
by reference
do you need to pass the variable?
Which of the following tells the computer to pass the variable's
address-of operator
address rather than a copy of its contents?
return statement Which of the following is NOT required in a void function?
printSum(a, b); Which of the following looks like a typical call to a void function?
Only functions defined where, in relation to the main function,
below
require a function prototype to be coded?
It is not necessary In a void function, what is true about the return statement?
Passing a variable's unique address to a function is referred to as
passing by reference
which of the following?
displaying two numbers Which of the following would be a practical use for a void function?
What value is a subscript assigned to access the first element in
0
a one-dimensional array?
Which of the following is a likely while statement used in the outer
while (swap == true)
loop of a bubble sort of an array called distances?
When passing an array to a function, which of the following should
[] come after the formal parameter name of the array in the function
header to indicate it is an array?
Given the following code, which statement displays each element
of the array, one line at a time?

cout << myArray[i] << endl; char myArray[4] = {'a', 'b', 'c', 'd'};

for (int i = 0; i < 4; i += 1)

---- code goes here ----


What are the most commonly used arrays in business applica-
one-dimensional and two dimensional arrays
tions?
integer What is the data type of a subscript used in an array?
Before using an array in a program, what first must be done to the
declare it
array?
6/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
With one-dimensional arrays, what indicates the variable's posi-
the subscript
tion within the array?
scalar variable What is another name for a simple variable?
contiguously How are arrays stored in memory locations?
Each variable within an array is referred to as which of the follow-
element
ing?
After the first pass in a typical ascending value bubble sort, what
the highest value
best describes the last element in an array?
When declaring and initializing an array, which of the following best
optional
describes the status of the initialValues section?
Which type of sort provides a quick and easy way to sort the items
bubble sort stored in an array, as long as the number of items is relatively
small?
Which statement correctly declares and populates a one-dimen-
sional array?

a.
char myArray{4} = ['10', '100', '1000', '10000'];
c. b.
int myArray[4] = {10, 100, 1000, 10000}; char myArray[4] = {'10', '100', '1000', '10000'};
c.
int myArray[4] = {10, 100, 1000, 10000};
CorrectCorrect
d.
int myArray{4} = [10, 100, 1000, 10000];
Which of the following statements declares a one-dimensional
int characters[2] = {45, 87};
array containing two integer values?
Which of the following is two or more arrays whose elements are
parallel array related by their corresponding position (subscript) in the arrays?
Select one:
How can the code in the following example best be described?

parallel arrays
int scoreThreshold[4] = {90, 80, 70, 60};

char letterGrade[4] = {'A', 'B', 'C', 'D'};


What, if anything, is needed to fix the following code so that the
elements of the array are printed, one line at a time?

change the initial value of i char myArray[4] = {'a', 'b', 'c', 'd'};

for (int i = 1; i < 4; i += 1)

cout << myArray[i] << endl;


What characteristic should the values used to populate an array
data type
and the array variables have in common?
Assigning initial values to an array is often referred to as doing
populating
what to the array?
sorting What term is defined as arranging data in a specific order?
an array What is a group of related variables that have the same data type?
What subscript should be used to access the fourth element in a
3
one-dimensional array?
Which of the following describes how an array is automatically
by reference
passed to a function?
7/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
Which of the following statements will store the user's entry into
cin >> numbers[1];
the second element of the numbers array?
Which of the following statements gets a string from the keyboard
getline(cin, myStr); until the newline character is encountered and assigns the string
to a variable named myStr?
Which string class function can be used to replace a sequence of
replace characters in a string variable with another sequence of charac-
ters.
What is the value of myStr when the following code is executed?

ABCd12345JK
string myStr = ABCdefghiJK";

myStr.replace(4, 5, "12345");
When using the ignore function, if you omit the numberOfChar-
1 acters argument, what is the default number of characters to
consume?
To duplicate a single character a specified number of times and
assign then assign the resulting string to a string variable, you would use
which of the following functions?
What will the value of newStr be after the following code is exe-
cuted?

1313 Mockingbird Lane


string newStr = "13 Mockingbird Lane";

newStr.insert(1, "31");
The string class provides which function to determine the number
length
of characters contained in a string variable?
Which of the following is NOT one of the fundamental data types
string
in C++.
What value will be returned by the myStr.length() statement in the
code below?

11
string myStr = "Hello there";

int strlen = myStr.length();


Which string class function can be used to search the contents
find of a string variable to determine whether it contains a specific
sequence of characters?
The functions contained within the string class are collectively
member
known as what type of functions?
The getline function will continue to read the characters entered
delimiter
at the keyboard until it encounters which character?
Which statement reads and consumes up to four characters until
cin.ignore(4, '\t');
the tab character is encountered?
Which statement will place 5 dollar sign ($) characters in the string
dollarStr.assign(5, '$');
dollarStr?
Which statement gets a string from the keyboard and stores it into
cin >> answer;
the answer variable?
What is the name of the operator that can be used to get string
extraction
input from the keyboard?
To remove one or more characters located anywhere in a string
erase
variable, which string class function would be used?

8/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
What value will be assigned to resultStr when the following code
is executed?

ello t
string newStr = "Hello there.";

resultStr = newStr.substr(1, 6);


getline What function can be used to get string input from the keyboard?
What function allows you to access a series of characters con-
substr
tained in a string variable?
In order to use the string data type in a program, what code must
a #include directive
be in your program?
Which of the following is the escape sequence that represents the
\n
newline character?
What is assigned to newStr after the following code is executed?

ello there!
string orgStr = "Hello there!";

string newStr = orgStr.substr(1, orgStr.length() - 1);


Which statement would be used to declare and initialize a string
string zipCode = "";
variable named zipCode?
+ What character is used as the concatenation operator in C++?
Which of the following terms best describe the process of con-
string concatention
necting (or linking) strings together?

9/9

You might also like