Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CMSC 140 Final Exam Review Questions And Answers Rated A+ New Update Assured Satisfaction

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
11-12-2024
Written in
2024/2025

What is a reference variable? When used as function parameters, how do they differ from normal parameters? - ️️A reference variable is a variable that, used as a function parameter, can be changed within the function. This is unlike normal variables, which any changes in a function to the variable will not remain outside the function. What does it mean to find the modulus of something? What operator is used in C++ to do this? - ️️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? - ️️The / operator is used to represent division in C++. What will be the data type of the result of division between two integers? - ️️The data type will be an integer. What will be the result of the expression 7 / 2 ? What will be different compared to the expression 7.0 / 2? - ️️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? What does it mean to increment something? What operator is used in C++ to do this? - ️️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? - ️️To decrement something is to decrease its value by 1. The operator in C++ is the -- (minus-minus) operator.

Show more Read less
Institution
CMSC 140
Course
CMSC 140

Content preview

CMSC 140 Final Exam Review
What is a reference variable? When used as function parameters, how do they differ
from normal parameters? - ✔️✔️A reference variable is a variable that, used as a
function parameter, can be changed within the function. This is unlike normal variables,
which any changes in a function to the variable will not remain outside the function.

What does it mean to find the modulus of something? What operator is used in C++ to
do this? - ✔️✔️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? - ✔️✔️The / operator is used to
represent division in C++.

What will be the data type of the result of division between two integers? - ✔️✔️The
data type will be an integer.

What will be the result of the expression ? What will be different compared to the
expression 7.? - ✔️✔️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?


What does it mean to increment something? What operator is used in C++ to do this? -
✔️✔️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? -
✔️✔️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? -
✔️✔️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.

int someNum = 2, anotherNum = 3, lastNum = 1;
bool aBool;
aBool = !(++someNum > (--anotherNum * lastNum++)); - ✔️✔️someNum: 3
anotherNum: 2

, lastNum: 2
abool: false

Name the three different types of loops. - ✔️✔️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. - ✔️✔️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
3. for loop: pretest, which means it will evaluate its expression before the loop executes
once.

What are the three parts of a for loop definition called? What do each of them do? -
✔️✔️The three parts of a for loop definition are initialization, test, and update.

initialization - the counter variable is initialized to a value. It executes once, the first time
the loop executes

test - the expression that evaluates to true or false, which controls the execution of the
loop

update - the expression that updates the counter variable. It executes at the end of each
loop.

What will be displayed on the screen after the execution of the following code?

int counter = 0;
bool moreThan20 = false;

while (!moreThan20)
{
if (counter != 6)
{
cout << counter << endl;
}

if (counter == 14)
{
cout << "...Getting close..." << endl;
}
else if (counter == 18)
{
cout << "...Almost there..." << endl;

Written for

Institution
CMSC 140
Course
CMSC 140

Document information

Uploaded on
December 11, 2024
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Brainarium Delaware State University
Follow You need to be logged in order to follow users or courses
Sold
1941
Member since
3 year
Number of followers
1044
Documents
23159
Last sold
1 day ago

3.8

331 reviews

5
154
4
62
3
57
2
16
1
42

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions