v QUESTION 1 What do the calls to exit(...) do? When exit(0) and exit(1) are cal
ID: 3857902 • Letter: V
Question
v
QUESTION 1
What do the calls to exit(...) do? When exit(0) and exit(1) are called, what receives these values and what is done with them?
the exit() function stops the program. The value is passed to the operating system which uses it for an error code
the exit() function stops the program. The value is discarded.
the exit() function is obsolete. There is no longer any such function in the C++ libraries
The exit() function temporarily stops the program, and sends the argument to the operating system which uses it for an error code. The operating system restarts the program after fixing the error.
10 points
QUESTION 2
Which statement is incorrect?
Extensive use of global variables is NOT a satisfactory replacement for the difficulties of parameter passing with functions
It is legal to replace the prototype
double totalCost(int numberParam, double priceParam);
with the more terse, alternate form
double totalCost(int, double);
A variable declared outside any function is said to be a global variable
In C++ Boolean value are represented only with the int values 0 for false and 1 for true
10 points
QUESTION 3
Which statement is incorrect?
Consider two blocks, one within another. If an identifier is declared as a variable in the innermost of these two blocks, one can access this variable from the outer block
A variable declared within a function block is said to be local to the function
Consider two blocks, one within another. C++ allows an identifier to be declared as a variable in each of these blocks
A local variable is created in the execution stack
10 points
QUESTION 4
Which is incorrect?
C++ predefined functions
make C++ harder than necessary
must use #include for the proper header file
are usually provided with the C++ compiler
are usually provided in libraries
10 points
QUESTION 5
Where can you NOT declare a variable in a C++ program?
Within the block of a void function
Within the parameter list of a function definition
Within the argument list of a function call
Within a block nested within another block
10 points
QUESTION 6
Here is a small program. Which of the statements about the variables is INcorrect?
#include <iostream>
const double NUM = 2.9345358;
double num = 3;
double numTimes(int x);
int main( )
{
using namespace std;
int value;
cout << “Enter a value, I’ll multiply it by “
<< NUM << endl;
cin >> value;
cout << “You entered “ << value
<< “ NUM times this is “ << numTimes(value)
<< endl;
return 0;
}
double numTimes(int x)
{
double d;
d = NUM * x;
return d;
}
the line
doublenumTimes(int x); is a function definition
The variable x is a parameter in function numTimes
the variable value is an argument in a call to numTimes
The line return d; in the function numTimes is necessary
10 points
QUESTION 7
Before a variable in C++ is used, it must be
used in some expression
defined
initialized
contain only letters, digits and underscores
10 points
QUESTION 8
If this code fragment were executed in an otherwise correct and complete program, what would the output be?
int a = 3, b = 2, c = 5
if (a > b)
a = 4;
if ( b > c)
a = 5;
else
a = 6;
cout << a << endl;
6
5
4
3
10 points
QUESTION 9
Which is a C++ keyword?
number_of_bars
a
total_weight
while
10 points
QUESTION 10
A l-value is
is designed for use by a left-handed person
an expression that can only be placed on the left of any operator such as +,*,/, etc.
assigned a value
can never have a value fetched from it
10 points
QUESTION 11
Any number with an exponent of zero is equal to
one.
zero.
itself.
ten.
10 points
QUESTION 12
Given the definition and code fragment:
int matrix[2][3];
int k = 0;
for(int i =0; i < 3; i++)
for (int j=0, j < 4; j++)
matrix[i][j] = k++;
The value of matrix[0][0] is
2
0
3
1
10 points
QUESTION 13
What is the output of the following code (assuming it is embedded in a correct and complete program)?
char letter[5] = {'o', 'k', 'c', 'e', 'g'};
for(int i = 4; i >= 0; i-- )
cout << letter[i];
cout << endl;
kceg followed by a character from an out of bounds access
ecko followed by a character from an out of bounds access
okceg
gecko
10 points
QUESTION 14
Are the following array initializations INcorrect?
int x[4] = {8, 7, 6, 5, 4};
int x[] = {8, 7, 6, 5, 4};
const int SIZE =4;
int x[SIZE];
int x[4] = {8, 7, 6};
10 points
QUESTION 15
In C++ array indices, that is subscript values, must be
positive
None is correct
Less than or equal to the declared size of the array
Non-negative, integery
10 points
QUESTION 16
If this code fragment were executed in an otherwise correct and complete program, what would the output be? .
int a = 3, b = 2, c = 5
if (a > b)
a = 4;
if ( b > c)
a = 5;
else
a = 6;
cout << a < endl;
4
3
5
6
10 points
QUESTION 17
Which of the following control structures requires curly braces?
if-else
while
switch
for
10 points
QUESTION 18
In distinguishing an expression as true or false, C++ sees which of the following as true?
0
1
true
Any non-zero value
10 points
QUESTION 19
Regarding the comma operator, which statement is incorrect?
ANSI C++ Standard specifies that expressions must be evaluated left to right
Expressions are evaluated in order defined by the compiler
Results in the value equal to the value of the first expression in the list
Is used to separate a list of expressions
10 points
QUESTION 20
Which of the following is NOT correct of the && operator?
It uses short circuit evaluation
It can have one operand
It has two operands
It returns true if both operands are true
the exit() function stops the program. The value is passed to the operating system which uses it for an error code
the exit() function stops the program. The value is discarded.
the exit() function is obsolete. There is no longer any such function in the C++ libraries
The exit() function temporarily stops the program, and sends the argument to the operating system which uses it for an error code. The operating system restarts the program after fixing the error.
Explanation / Answer
Question 1:-
The exit() function temporarily stops the program, and sends the argument to the operating system which uses it for an error code. The operating system restarts the program after fixing the error.
Question 2:-
In C++ Boolean value are represented only with the int values 0 for false and 1 for true
Question 3:-
Consider two blocks, one within another. If an identifier is declared as a variable in the innermost of these two blocks, one can access this variable from the outer block
Question 4:-
are usually provided in libraries
Question 5:-
within the arguement list of function call
Question 6:-
double numTime(int x);
Question 8:-
6
Question 9:-
while
Question 10:-
Question 11:-
one
Question 12:-
The value of matrix[0][0] = 0
Question 13:-
gecko
Question 14:-
int x[4]={8,7,6,5,4}
Question 15:-
None is correct
Question 16:-
6
Question 17:-
switch
Question 18 :-
any non zero value
Question 19:-
ANSI C++ standard specifies that expression must be evaluated left to right
Question 20 :
IT CAN HAVE ONE OPERAND
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.