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 midterm Questions and Answers(A+ Solution guide)

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

Code the following statements using combined assignment operators: 1. price1 is equal to price1 plus 5. 2. price2 is equal to price2 times 7.0 3. price3 is equal to price3 divided by 4.5 4. totalPrice is equal to totalPrice modulus 3 Hint: Things like an equal sign or multiply sign but initialize the variables. - ️️double price1 = 3.45, price2 = 5.79, price3 = 15.64; int totalPrice = 98; //1. price1 += 5; //2. price2 *= 7.0; //3. price3 /= 4.5; //4. totalPrice %= 3;

Show more Read less
Institution
CMSC 140
Course
CMSC 140

Content preview

CMSC 140 midterm
Code the following statements using combined assignment operators:
1. price1 is equal to price1 plus 5.
2. price2 is equal to price2 times 7.0
3. price3 is equal to price3 divided by 4.5
4. totalPrice is equal to totalPrice modulus 3

Hint: Things like an equal sign or multiply sign but initialize the variables. - ✔️✔️double
price1 = 3.45, price2 = 5.79, price3 = 15.64;
int totalPrice = 98;

//1.
price1 += 5;
//2.
price2 *= 7.0;
//3.
price3 /= 4.5;
//4.
totalPrice %= 3;

What does the following code output to the user?


int A = 10, B = 17, C = 2;
double D = 17.01;
bool boolValue = true;

if (A > B)
{
cout << "Good afternoon, sir." << endl;
if (A == C)
{
cout << "Fine weather today we're having." << endl;
}
}
else if (D < B)
{
cout << "It looks like it will rain later on." << endl;
}
else
{
cout << "Good morning." << endl;

, if (boolValue == true)
{
cout << "The sun's bright at this time." << endl;
}
else
{
cout << "We've got a lot of cloud cover now." << endl;
}
} - ✔️✔️//The code outputs:
//Good morning.
//The sun's bright at this time.

What does the following code ouput to the user?

int num1 = 10, num2 = 13, num3 = 10, square, quotient;
bool firstBool = true;
bool secondBool = false;

if (firstBool && num2 < num3)
{
cout << "Good day!" << endl;
if (firstBool && !(secondBool))
{
cout << "Fine weather this morning." << endl;
}
else
{
cout << "The weather's a bit muggy, isn't it?" << endl;
}
}
else if (!firstBool || !secondBool)
{
cout << "Hello!" << endl;
if (firstBool && (secondBool == false))
{
cout << "Top of the morning to you!" << endl;
}
if (num1 == num3)
{
cout << "The sun is shining bright today." << endl;
}
else
{
cout << "It's a bit chilly out, don't you think?" << endl;
}
}

Written for

Institution
CMSC 140
Course
CMSC 140

Document information

Uploaded on
December 11, 2024
Number of pages
6
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