Take Assessment: C++ test chapters 4-7 Assistive Technology Tips [opens in new w
ID: 3635567 • Letter: T
Question
Take Assessment: C++ test chapters 4-7Assistive Technology Tips [opens in new window]
Name C++ test chapters 4-7
Instructions
Multiple Attempts Not allowed. This Test can only be taken once.
Force Completion This Test can be saved and resumed later.
Show Question Completion Status:
Question 1 text Question 1 2 points Save
You must have a return statement in a non
-void function.
Question 1 answers
True
False
Question 2 text Question 2 2 points Save
Variables defined in the function header are called ________.
Question 2 answers
arguments
parameters
local variables
global variables
Question 3 text Question 3 2 points Save
How many times does the following code print "Welcome to C++"?
int count = 0;
while (count < 10)
{
cout << "Welcome to C++";
count++;
}
Question 3 answers
11
0
9
10
Question 4 text Question 4 2 points Save
Each time a function is invoked, the system stores parameters and local variables in an area of memory, known as ________, which stores elements in last
-in first-out fashion.
Question 4 answers
a stack
an array
a heap
storage area
Question 5 text Question 5 2 points Save
The actual parameters of a function must match the formal parameters in type, order, and number.
Question 5 answers
True
False
Question 6 text Question 6 2 points Save
Assume int t[]={1,2,3,4}. What is t[4]?
Question 6 answers
4
3
accessing t[4] may result in a runtime error
5
Question 7 text Question 7 2 points Save
Review the following code:
void nPrint(char ch,int n)
{
while (n>0)
{
cout << ch;
n--;
}
}
What is k after invoking nPrint('a',k) below?
int k=2;
nPrint('a',k);
Question 7 answers
2
1
3
0
Question 8 text Question 8 2 points Save
When you invoke a function with a parameter, the value of the argument is passed to the parameter. This is referred to as ________
Question 8 answers
call by name
call by value
function invocation
call by reference
Question 9 text Question 9 2 points Save
Suppose int i=5, which of the following can be used as an index for arrray double t[100]?
Question 9 answers
rand()/100
i
i+10
rand%100
Question 10 text Question 10 2 points Save
What is balance after the following code is executed?
int balance =0;
while (balance >= 1)
{
if (balance<9)
continue;
balance = balance -9;
}
Question 10 answers
0
The loop does not end
2
1
Question 11 text Question 11 2 points Save
The signature of a function consists of the function name, parameter list and return type.
Question 11 answers
True
False
Question 12 text Question 12 2 points Save
A void function does not return a value.
Question 12 answers
True
False
Question 13 text Question 13 2 points Save
You may have a return statement in a void function.
Question 13 answers
True
False
Question 14 text Question 14 2 points Save
The array index of the first element in an array is 0.
Question 14 answers
True
False
Question 15 text Question 15 2 points Save
Variables defined inside a function are called ________.
Question 15 answers
global variables
parameters
local variables
arguments
Question 16 text Question 16 2 points Save
The return statement in the following code causes syntax errors.
int main()
{
int max=0;
if (max !=0)
cout << max;
else
return 0;
}
Question 16 answers
True
False
Question 17 text Question 17 2 points Save
What is the output of the following progam?
#include <iostream>
using namespace std;
int main()
{
int x[]={120,200,016};
for (int i=0;i<3;i++)
cout << x[i] << " ";
}
Question 17 answers
120 200 14
016 is a syntax error. It should be written as 16.
120 200 20
120 200 16
Question 18 text Question 18 2 points Save
Which of the following function results in 8.0?
Question 18 answers
pow(8.5, 3.4)
max(8.5, 8.0)
floor(8.5)
ceil(8.5)
Question 19 text Question 19 2 points Save
Analyze the following code
int main ()
{
int i =0;
for (i = 0; i <10; i++);
cout <<(i+4);
}
Question 19 answers
The program compiles despite the semicolon (;) on the for loop line, and displays 4.
The for loop in this program is same as for (i =0;i<10;i++){};cout<< i+4;
The program compiles despite the semicolon (;) on the for loop line, and displays 14.
The program has a syntax error because of the semicolon (;) on the for loop line.
Question 20 text Question 20 2 points Save
If a parameter is a reference variable, this parameter becomes an alias for the original variable. This is referred to as ________.
Question 20 answers
pass by name
pass by reference
function invocation
pass by value
Explanation / Answer
1st answer: TRUE
2nd answer: arguments
3rd answer: 10
4th answer: stack
5th answer: TRUE
6th answer: Runtime error
7th answer: 2
8th answer: call by value
9th answer: i, i+10, rand() % 100
10th answer: 0
Rate me lfiesaver and I will send other answers to your inbox
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.