Answer the Following Questions: FOR C++ 1) The statement: loop += count--; has t
ID: 3662810 • Letter: A
Question
Answer the Following Questions:
FOR C++
1) The statement:
loop += count--;
has the same effect as the statements:
count = count+1;
loop = loop - count;
True or False
2) Due to the way computers represent floating point numbers, not every number on the number line can actually be stored into a variable of type double or float.
True or False
3)"Keywords" are reserved names (such as if or while) that cannot be used by programmers as the name of variables, constants or functions.
True or False
4)When C++ evaluates the expression:
if (a < 3 || b > x || c != 12) { ... }
when a equals 10, C++ will short-circuit, report the answer as false,not evaluate the entire logical expression to determine the answer and skip over the statement block inside the { }s.
True or False
5) Within a C++ program, all variables regardless of their type go thru a "life-cycle" which includes declaration, initialization, usage and finally dying off when the variable falls out of scope.
True or False
6) In C++, the body of a for loop will always run atleast once.
True or False
7)C++ programs are not case-sensitive.
True or False
8) When a function wants to return more than one value, it must use pass-by-reference parameters to return some of the data back to the calling program.
True or False
9) in C++, the body of a do-while loop is may never run even once.
True or False
10) One difference between a declared variable and a declared constant is that a constant’s value can vary at run-time, but a declared variable’s value cannot be changed after it is initialized.
True or False
11) A function may accept either pass-by-reference or pass-by-value parameters, but not both in the same function.
True or False
12) In C++, when double variables are left uninitialized, their initial value will not equal zero.
True or False
13) When working with floating-point numerical values, programmers must use care because floating-point numerical representations are always inexact.
True or False
14) When working with an if statement, an else clause is always required.
True or False
15) The logical expression: ( x >= y ) executes the same as the logical expression: ( x > y && x ==y ).
True or False
16) Pam the Programmer wants to ensure that a few lines of code are only run when a certain circumstance occurs. Which kind of statement should she use?
Select one:
a. an assignment statement
b. None of the choices below are correct
c. an if statement
d. a do-while loop
17) Commenting your C++ code is very important because
Select one:
a. All of the choices listed are correct
b. very often, a programming project involves many individuals who will want to understand how your code works, even though you were its sole author
c. many years from now, it might need to be maintained by someone else who will not know what you meant your code to do
d. a few days after you first write it, you might need to make changes and will have lost your train of thought unless you explicitly state what you are trying to do
18) In the computation: a = b * c + f / g;
C++ will calculate the answer by performing
Select one:
a. the division and subtraction first, followed by the multiplication and addition
b. the multiplication and division first, followed by the addition and subtraction
c. the subtraction and addition first, followed by the multiplication and division
d. the addition and division first, followed by the multiplication and subtraction
19) When using a return statement, the parenthesis around the value being returned to the calling program are
Select one:
a. optional
b. required only in certain circumstances
c. required
d. never allowed
20) Consider the expression: !( false && ( true || false ) )
Select one:
a. At run-time, this expression evaluates to the value true
b. Due to syntax errors, this expression cannot be compiled successfully
c. Due to run-time errors, this expression cannot be evaluated
d. At run-time, this expression evaluates to the value false
21) Each statement in C++ ends with a
Select one:
a. semicolon (that is a ;) and more than one statement can be present on a single textual line of code
b. pound sign (that is a #) and more than one statement can be present on a single textual line of code
c. new line and only one statement can be present on a single textual line of code
d. semicolon (that is a ;) and only one statement can be present on a single textual line of code
22) When evaluating a complex expression that lack parenthesis such as
x = a + b - c * d / e + f;
C++ will always calculate the answer running * and / before + and - computing the answer as if the user entered
x = (((a + b) - ((c * d) / e)) + f);
True or False
23) When C++ executes the statement:
x = 2 % 28;
x will be given the value
Select one:
a. 2
b. 28
c. 0
d. 1
Explanation / Answer
1) The statement:
loop += count--;
has the same effect as the statements:
count = count+1;
loop = loop - count;
True or False
Ans:false
2) Due to the way computers represent floating point numbers, not every number on the number line can actually be stored into a variable of type double or float.
True or False
Ans:False
3)"Keywords" are reserved names (such as if or while) that cannot be used by programmers as the name of variables, constants or functions.
True or False
Ans:True
4)When C++ evaluates the expression:
if (a < 3 || b > x || c != 12) { ... }
when a equals 10, C++ will short-circuit, report the answer as false,not evaluate the entire logical expression to determine the answer and skip over the statement block inside the { }s.
True or False
Ans:False
5) Within a C++ program, all variables regardless of their type go thru a "life-cycle" which includes declaration, initialization, usage and finally dying off when the variable falls out of scope.
True or False
Ans:True
6) In C++, the body of a for loop will always run atleast once.
True or False
Ans: False
7)C++ programs are not case-sensitive.
True or False
Ans:False
8) When a function wants to return more than one value, it must use pass-by-reference parameters to return some of the data back to the calling program.
True or False
Ans:True
9) in C++, the body of a do-while loop is may never run even once.
True or False
Ans:False
10) One difference between a declared variable and a declared constant is that a constant’s value can vary at run-time, but a declared variable’s value cannot be changed after it is initialized.
True or False
Ans:False
11) A function may accept either pass-by-reference or pass-by-value parameters, but not both in the same function.
True or False
Ans:False
12) In C++, when double variables are left uninitialized, their initial value will not equal zero.
True or False
Ans:True
13) When working with floating-point numerical values, programmers must use care because floating-point numerical representations are always inexact.
True or False
Ans:False
14) When working with an if statement, an else clause is always required.
True or False
Ans:False
15) The logical expression: ( x >= y ) executes the same as the logical expression: ( x > y && x ==y ).
True or False
Ans:False
16) Pam the Programmer wants to ensure that a few lines of code are only run when a certain circumstance occurs. Which kind of statement should she use?
Select one:
a. an assignment statement
b. None of the choices below are correct
c. an if statement
d. a do-while loop
Ans:c. an if statement
17) Commenting your C++ code is very important because
Select one:
a. All of the choices listed are correct
b. very often, a programming project involves many individuals who will want to understand how your code works, even though you were its sole author
c. many years from now, it might need to be maintained by someone else who will not know what you meant your code to do
d. a few days after you first write it, you might need to make changes and will have lost your train of thought unless you explicitly state what you are trying to do
Ans:a. All of the choices listed are correct
18) In the computation: a = b * c + f / g;
C++ will calculate the answer by performing
Select one:
a. the division and subtraction first, followed by the multiplication and addition
b. the multiplication and division first, followed by the addition and subtraction
c. the subtraction and addition first, followed by the multiplication and division
d. the addition and division first, followed by the multiplication and subtraction
Ans: b. the multiplication and division first, followed by the addition and subtraction
19) When using a return statement, the parenthesis around the value being returned to the calling program are
Select one:
a. optional
b. required only in certain circumstances
c. required
d. never allowed
Ans:b. required only in certain circumstances
20) Consider the expression: !( false && ( true || false ) )
Select one:
a. At run-time, this expression evaluates to the value true
b. Due to syntax errors, this expression cannot be compiled successfully
c. Due to run-time errors, this expression cannot be evaluated
d. At run-time, this expression evaluates to the value false
Ans:b. Due to syntax errors, this expression cannot be compiled successfully
21) Each statement in C++ ends with a
Select one:
a. semicolon (that is a ;) and more than one statement can be present on a single textual line of code
b. pound sign (that is a #) and more than one statement can be present on a single textual line of code
c. new line and only one statement can be present on a single textual line of code
d. semicolon (that is a ;) and only one statement can be present on a single textual line of code
Ans:a. semicolon (that is a ;) and more than one statement can be present on a single textual line of code
22) When evaluating a complex expression that lack parenthesis such as
x = a + b - c * d / e + f;
C++ will always calculate the answer running * and / before + and - computing the answer as if the user entered
x = (((a + b) - ((c * d) / e)) + f);
True or False
Ans:True
23) When C++ executes the statement:
x = 2 % 28;
x will be given the value
Select one:
a. 2
b. 28
c. 0
d. 1
Ans:a.2