Not a reason why programmers write their own functions


1.The body of a while statement does not execute if the loop-continuation condition is false.

A) True
B) False
2.The setw parameterized stream manipulator sets the minimum field width in characters for the next value to be displayed.
A) True
B) False
3.A do...while loop will not execute if its loop continuation condition is false before the loop is started.
A) True
B) False
4.Sentinel-controlled repetition terminates when ________.
A) the application terminates
B) the sentinel value is encountered
C) the user enters -1
D) None of the above.
5.Assuming that variables value1 and value2 are both declared as ints,which of the following statements causes the result of the calculation to be truncated?
A)double result = static_cast(value1) / value2
B)double result = value2 + static_cast(value1)
C) double result = value1 / value2
D) All of the above.
6.Sentinel-controlled repetition is also called ________ repetition.
A) definite
B) indefinite
C) infinite
D) Both b and c.
7.Fatal logic errors __________.
A) are detected by the compiler.
B) cause the application to crash.
C) can be caused by division by zero.
D) Both b and c.
8.When a double containing the value 2.718 is cast to an int, the int will contain the value _______?
A) 2.7
B) 3
C) 2
D) a double can not be cast to an int.
9.When an int is divided by a double, the result is ___________.
A) a double value
B) an int value
C) a syntax error
D) a fatal logic error
10.The initial value of the control variable is one of the four essential elements of counter-controlled repetition.
A) True
B) False
11.In the for statement header, the expressions are separated by commas (,).
A) True
B) False
12.The following code varies the control variable in increments of 6 from 6 to 66: for ( int i = 6; i <= 66; i += 6 );
A) True
B) False
13.The pow function is declared in the math library, which is accessed by including the header file.
A) True
B) False
14.Which of the following is not a valid increment (or decrement) of the control variable in a for repetition statement header?
A) i*=10
B) i++
C) i+1
D) i-=1
15.In a for loop, the control variable is incremented (or decremented) _______?
A) after the body of the loop executes
B) before the body of the loop executes
C) while the loop-continuation condition is false
D) while the body of the loop executes
16.The for header ________ can be used to vary the control variable over the odd numbers between 1 and 10.
A) for (int i=1; i<=10; i+=1)
B) for (int i=1; i<=10; i+=2)
C) for (int i=1; i<=10; i-=1)
D) for (int i=1; i<=10; i-=2)
17.The body of the for loop with the header: for (int i=1; i<=10; i-=1) will be executed __________ times.
A) a very large number of 
B) 9
C) 10
D) 11
18.The ________ function returns the value of one number raised to the power of another number.
A) power
B) exponent
C) pow
D) exp
19.The body of a Do-While loop will always execute at least once, whereas the body of a For loop may never execute.
A) True
B) False
20.Which of the following is NOT a C++ looping control statement type?
A) while
B) for
C) do-while
D) switch
21.What is the value of 'sum' after execution of the following code? (All variables are of type 'int'.)
sum = 0; 
for (counter = 2; counter <= 5; counter++) 
{
sum = sum + (2 * counter); 
}
A) 28
B) 18
C) 10
D) 30
E) none of the above
22.A constant expression in a case label can be a character literal, an integer literal or a floating-point literal.
A) True
B) False
23.A switch statement will execute all statements after a matching case label until a break statement or the end of the switch statement.
A) True
B) False
24.The _______ signifies the end of a switch statement.
A) end keyword
B) } character
C) break keyword
D) default keyword
25._______ is a valid case label.
A) case: 'A'
B) case: "A"
C) case 'A':
D) case: 1
26.If the controlling expression in the switch statement is not equal to any of the case labels and there is no default case, _______.
A) an error occurs
B) an infinite loop occurs
C) the program continues execution with the next statement after the end of the switch
D) the first case's statements are executed
27._______ separates the case label from the code that will execute if the case label matches the controlling expression.
A) A colon
B) An underscore
C) The break keyword
D) A semicolon
28.The correct syntax for a default case is _______?
A) defalut case
B) default
C) default case:
D) default:
29.In C++, programmers break applications into smaller pieces using functions and classes.
A) True
B) False
30.A function name can be any valid identifier that is not reserved for use by C++.
A) True
B) False
31.When using the debugger, if the next statement to execute is a function call and the Step Into command is used, control is transferred to the called function.
A) True
B) False
32.A function definition is made up of _______.
A) a function header
B) a function body
C) a function name
D) All of the above.
33.How many values can a return statement return to a caller?
A) zero
B) one 
C) any number
D) Both a and b.
34.Which of the following statements correctly returns 'int' variable 'value' from a function?
A) return value();
B) return int value;
C) value return;
D) return value;
35.The first part of a function definition (including the return type, function name, and the parameter list) is known as the function _______.
A) body
B) title
C) caller
D) header
36.The _______ function from the cmath library calculates the square root of the double value passed as an argument.
A) squareRoot
B) root
C) sqrt
D) square
37.If a C++ function does not use parameters, you still must put parentheses around the empty parameter list.
A) True
B) False
38.Which of the following is NOT a reason why programmers write their own functions?
A) to help organize and clarify programs
B) to make programs execute faster than they would with sequential flow of control
C) to allow the reuse of the same code (function) within the same program
D) to allow the reuse of the same code (function) within another program
39.When parameters are passed between the calling code and the called function, the calling and the called parameters are matched by:
A) their data types
B) their relative positions in the calling and the called parameter lists
C) their names
D) whether they are inputs to or outputs from the function
40.Which of the following is the correct function 'heading' for a parameterless function named 'PrintStars'?
A) void PrintStars
B) void PrintStars;
C) void PrintStars( )
D) void PrintStars( );
E) void PrintStars (int n) 

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Not a reason why programmers write their own functions
Reference No:- TGS081386

Now Priced at $40 (50% Discount)

Recommended (94%)

Rated (4.6/5)