CMSC 140 Final Exam Review Exam
Questions With Correct Answers
What does it mean to increment something? What operator is used in C++ to do
| | | | | | | | | | | | | | |
this? - CORRECT ANSWER✔✔-To increment something is to increase its value by
| | | | | | | | | | | |
1. The operator in C++ is the ++ (plus-plus) operator.
| | | | | | | | |
What does it mean to decrement something? What operator is used in C++ to do
| | | | | | | | | | | | | | |
this? - CORRECT ANSWER✔✔-To decrement something is to decrease its value by
| | | | | | | | | | |
1. The operator in C++ is the -- (minus-minus) operator.
| | | | | | | | | |
What is the difference in using a increment/decrement operator in postfix or
| | | | | | | | | | | |
prefix? - CORRECT ANSWER✔✔-In prefix mode, the value is incremented before
| | | | | | | | | | |
used in any expression in the same statement. In postfix mode, the value is
| | | | | | | | | | | | | |
incremented after used in any expression in the same statement.
| | | | | | | | |
What does it mean to find the modulus of something? What operator is used in
| | | | | | | | | | | | | | |
C++ to do this? - CORRECT ANSWER✔✔-To find the modulus is to find the
| | | | | | | | | | | | | |
remainder after the division of two numbers. The operator % is used in C++.
| | | | | | | | | | | | |
What operator is used in C++ to represent division? - CORRECT ANSWER✔✔-The
| | | | | | | | | | |
/ operator is used to represent division in C++.
| | | | | | | | |
What will be the data type of the result of division between two integers? -
| | | | | | | | | | | | | | |
CORRECT ANSWER✔✔-The data type will be an integer.
| | | | | | |
, What will be the result of the expression ? What will be different compared
| | | | | | | | | | | | | | | | |
to the expression 7.? - CORRECT ANSWER✔✔-3 - it will be different from the
| | | | | | | | | | | | | | | |
second expression, which is 3.5, since because it is integer division any numbers
| | | | | | | | | | | | |
after the decimal are ignored.
| | | |
What will the variables 'someNum', 'anotherNum', 'lastNum', and 'aBool' contain
| | | | | | | | | |
after the execution of the following code?
| | | | | |
int someNum = 2, anotherNum = 3, lastNum = 1;
| | | | | | | | |
bool aBool; |
aBool = !(++someNum > (--anotherNum * lastNum++)); - CORRECT ANSWER✔✔-
| | | | | | | | |
someNum: 3 |
anotherNum: 2 |
lastNum: 2 |
abool: false |
Name the three different types of loops. - CORRECT ANSWER✔✔-1. while loop
| | | | | | | | | | | |
2. do-while loop
| |
3. for loop
| |
For each type of loop, state if the loop is pretest or post test, and explain what
| | | | | | | | | | | | | | | | |
that means. - CORRECT ANSWER✔✔-1. while loop: pretest, which means it will
| | | | | | | | | | | |
evaluate its expression before the loop executes once.
| | | | | | |
2. do-while loop: post test, which means it will evaluate its expression after the
| | | | | | | | | | | | | |
loop executes once
| |
Questions With Correct Answers
What does it mean to increment something? What operator is used in C++ to do
| | | | | | | | | | | | | | |
this? - CORRECT ANSWER✔✔-To increment something is to increase its value by
| | | | | | | | | | | |
1. The operator in C++ is the ++ (plus-plus) operator.
| | | | | | | | |
What does it mean to decrement something? What operator is used in C++ to do
| | | | | | | | | | | | | | |
this? - CORRECT ANSWER✔✔-To decrement something is to decrease its value by
| | | | | | | | | | |
1. The operator in C++ is the -- (minus-minus) operator.
| | | | | | | | | |
What is the difference in using a increment/decrement operator in postfix or
| | | | | | | | | | | |
prefix? - CORRECT ANSWER✔✔-In prefix mode, the value is incremented before
| | | | | | | | | | |
used in any expression in the same statement. In postfix mode, the value is
| | | | | | | | | | | | | |
incremented after used in any expression in the same statement.
| | | | | | | | |
What does it mean to find the modulus of something? What operator is used in
| | | | | | | | | | | | | | |
C++ to do this? - CORRECT ANSWER✔✔-To find the modulus is to find the
| | | | | | | | | | | | | |
remainder after the division of two numbers. The operator % is used in C++.
| | | | | | | | | | | | |
What operator is used in C++ to represent division? - CORRECT ANSWER✔✔-The
| | | | | | | | | | |
/ operator is used to represent division in C++.
| | | | | | | | |
What will be the data type of the result of division between two integers? -
| | | | | | | | | | | | | | |
CORRECT ANSWER✔✔-The data type will be an integer.
| | | | | | |
, What will be the result of the expression ? What will be different compared
| | | | | | | | | | | | | | | | |
to the expression 7.? - CORRECT ANSWER✔✔-3 - it will be different from the
| | | | | | | | | | | | | | | |
second expression, which is 3.5, since because it is integer division any numbers
| | | | | | | | | | | | |
after the decimal are ignored.
| | | |
What will the variables 'someNum', 'anotherNum', 'lastNum', and 'aBool' contain
| | | | | | | | | |
after the execution of the following code?
| | | | | |
int someNum = 2, anotherNum = 3, lastNum = 1;
| | | | | | | | |
bool aBool; |
aBool = !(++someNum > (--anotherNum * lastNum++)); - CORRECT ANSWER✔✔-
| | | | | | | | |
someNum: 3 |
anotherNum: 2 |
lastNum: 2 |
abool: false |
Name the three different types of loops. - CORRECT ANSWER✔✔-1. while loop
| | | | | | | | | | | |
2. do-while loop
| |
3. for loop
| |
For each type of loop, state if the loop is pretest or post test, and explain what
| | | | | | | | | | | | | | | | |
that means. - CORRECT ANSWER✔✔-1. while loop: pretest, which means it will
| | | | | | | | | | | |
evaluate its expression before the loop executes once.
| | | | | | |
2. do-while loop: post test, which means it will evaluate its expression after the
| | | | | | | | | | | | | |
loop executes once
| |