Answer the Following Questions: FOR C++ And number the answers please :) 1) The
ID: 664842 • Letter: A
Question
Answer the Following Questions:
FOR C++ And number the answers please :)
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 given statement is FALSE.
2) The statement, “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” is TRUE.
3) The statement, “ Key words" are reserved names (such as if or while) that cannot be used by programmers as the name of variables, constants or functions” is TRUE.
4) Consider the expression:
if (a < 3 || b > x || c != 12)
{ ...
}
The statement, “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” is TRUE.
5) The statement, “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” is TRUE.
6) The statement, “In C++, the body of a for loop will always run atleast once” is TRUE.
7) The statement, “C++ programs are not case-sensitive” is FALSE.
8) The statement, “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” is FALSE.
9) The statement, “in C++, the body of a do-while loop is may never run even once” is FALSE.
10) The statement, “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” is TRUE.
11) The statement, “A function may accept either pass-by-reference or pass-by-value parameters, but not both in the same function” is FALSE.
12) The statement, “In C++, when double variables are left uninitialized, their initial value will not equal zero” is TRUE.
13) The statement, “When working with floating-point numerical values, programmers must use care because floating-point numerical representations are always inexact” is FALSE.
14) The statement, “When working with an “if” statement, an else clause is always required” is FALSE.
15) The statement, “The logical expression: ( x >= y ) executes the same as the logical expression: ( x > y && x ==y ) ” is TRUE.
16)
The if statement is used to execute pam the programmer wants to ensure that a few lines of code are only run when a certain circumstance occurs.
Thus, the correct option is (c ) an if statement.
17) The correct option is (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.
18) The correct option is (a) the multiplication and division first, followed by the addition and subtraction.
19) The correct option is (a) optional.
20) The correct option is (a) At run-time, this expression evaluates to the value true.
21) The correct option is (a) semicolon (that is a ;) and more than one statement can be present on a single textual line of code.
22) The statement, “C++ will always calculate the answer running * and / before + and - computing the answer as if the user entered expression” is TRUE.
23)
Example C++ code:
#include<iostream>
using namespace std;
int main()
{
double x = 2 % 28;
cout<<"x="<<x;
system("PAUSE");
}
The output of the code as x=2.
Thus, the correct option is (a) 2