Visual C++ Programming Final
Visual C++ Programming Final
int xNum = 0;
int yNum = 0;
do
xNum: 0 is printed
{
yNum += 1;
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;
yNum = 0;
zNum = 0;
endless loop
do
zNum += xNum;
int x = 0;
2 do
x += 3;
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 main()
}
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
{
yNum += 1;
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 << "Total cost: $" << price + price * .05 << endl;
int x = 3;
2 do
x++;
int num1;
4/9
CSC 2265 Visual C++ Programming Final
Study online at https://quizlet.com/_6ija9d
cout << num1 *.10;
}
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
{
xNum += yNum;
val1 = 10;
val2 = 25;
printSum(val1, val2);
val1 and val2 are the wrong type
}
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'};
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};
change the initial value of i char myArray[4] = {'a', 'b', 'c', 'd'};
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?
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";
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.";
ello there!
string orgStr = "Hello there!";
9/9