1

Question 1 (8 points): Choose the Correct Answer (2 points for each question) 1. What are...

Question

Question 1 (8 points): Choose the Correct Answer (2 points for each question) 1. What are...

Question 1 (8 points): Choose the Correct Answer (2 points for each question) 1. What are the values of the variables x and y
Question 1 (8 points): Choose the Correct Answer (2 points for each question) 1. What are the values of the variables x and y after executing the following code? intx=0,y-2; if (x0) y-13 else y-2;) c, x = 1,y=1 d.x-1,y 2 of the following will output Yes only if the integer variable numis either 2.3, 4, or 5? a. if ((2--num) II (nurn<-5)) {cout << "Yes" << endl; } miT b. İfQ2(num) & (num >-5)) {cout << "Yes"くくendl; } c. if((2<=num) && (num<=5)) {cout << "Yes" << endl; } en d, if (2 <= num <= 5) {cout << "Yes" << endl; } 3. What value is stored in y after executing the following code? Note that the code has purposely not been indented intx-9,y=0; if (x <5) if (x>3) y-2 else y-3; b. y-1 c, y = 2 d. y 3 a. y=0 4. What will the following code output? int x, y; x-1; cout << x <<<<y << endl; b. 02 c. 20 d. 12 . 00

Answers

1.

int x=0, y=2;
if(x==0)
{   y=1;}
else
{   y=2;}


since initial value before if condition evaluation of x is 0, the if condition is satisfied (true)
and thus the code inside if block executes .. therefore y is assigned a value 1.
since if condition was true, else block won't be executed
therefore, the values of x and y afterwards will be (a) x=0, y=1;

-----------------------------------------------------

2. (a) this will output "Yes" because both the conditions are satisfied and with the OR operator, even if one is satisfied, it will be true

(b) this will output "Yes" only for num=5, the if condition will be false for as greater than equal to 5 is false when num is 2 or 3 or 4

(c) this will output "Yes" as both the conditions will always be true for num=2 or 3 or 4 or 5

(d) compilation error, number can't be compared this way together with two conditions

-----------------------------------------------------

3. 0


The second if clause is nested inside the first if clause
and the else condition will correspond to the second nested if clause only

First if condition is not satisfied as x=9 so x can't be less than 5
therefore none of the statements further are executed and the value of y remains 0.

-----------------------------------------------------

4. (b) 0 2

x-- will decrement the value of x by 1 after using the previous value of x for calculation (as this is port decrement operator)
thus, x's value is 1 for calculation y= 1* 2
so, y =2
and then x will be decremented to 0.


Similar Solved Questions

1 answers
The figure below shows a history graph at x-2 m of a wave moving to the...
The figure below shows a history graph at x-2 m of a wave moving to the right at 1 m/s. Draw a snapshot graph of the wave at t-1s. y (cm) t (s) -2-12 3/4 5 6 (A) Draw a history graph first, then explain briefly the procedure to draw the snapshot graph. (B) Draw a neat snapshot graph with correct uni...
1 answers
Given the following single-step reaction, draw the curved-arrow mechanism.
Given the following single-step reaction, draw the curved-arrow mechanism.Add curved arrow only to the reactants:PLEASE also include lone electrons and arrows only to reactants thanks...
1 answers
Find the Payback period for the following project: Project Y Initial Outlay $18,100 Year 1 $5,460...
Find the Payback period for the following project: Project Y Initial Outlay $18,100 Year 1 $5,460 Year 2 $5,520 Year 3 $5,740 Year 4 $6,150 The answer should be calculated to two decimal places....
1 answers
Quiz I4. Monitor a phone call. Classify the call as a voice call (V), if someone...
Quiz I4. Monitor a phone call. Classify the call as a voice call (V), if someone is speaking: or a data call (D) if the call is carrying a modem or fax signal. Classify the call as long (L) if if the call lasts for more than three minutes; otherwise classify the call as brief (B). Based on data coll...
1 answers
Why do galvanic cells need a salt bridge?
Why do galvanic cells need a salt bridge?...
1 answers
Question 16 Which of the following reactions represents the disproportionation of chlorine in water? C12(g) +H30(7)=CH(aq)...
Question 16 Which of the following reactions represents the disproportionation of chlorine in water? C12(g) +H30(7)=CH(aq) + HCl(aq) + OH(aq) Cl2(g) + H2O(1)=CH(aq) +H+ (aq) + HClO(aq) Cl2(g) + H2O(1) CH(aq) + H2(g) + Clo+(aq) Cl2(g) + 2H2O(1) Cl(aq) + 3H*(aq) + HClO3(aq) Cl2(g) + 4H2O(1 =CH(aq) + S...
1 answers
Write a discussion to explain sumatriotan, morphine and quetiapine including their side effects, adverse effect, and...
write a discussion to explain sumatriotan, morphine and quetiapine including their side effects, adverse effect, and contraindications...
1 answers
Need help please EXERCISE 25.11 blood pressure dropped to 70 mm Hg. Robert effort, and crackles...
need help please EXERCISE 25.11 blood pressure dropped to 70 mm Hg. Robert effort, and crackles were heard Robert was transported to the coronary care unit for further scenario, or clinical case. This exercise requires evaluation. Doctors performed an echocandiogram, which revealed multipke syste...
1 answers
3. The DNA packing ratio is one of important parameters in biology. It is defined as...
3. The DNA packing ratio is one of important parameters in biology. It is defined as voume of genome (size of genome * volume of a DNA base pair) volume of compartment such as nucleus pack The volume of a DNA base pair is Inn/bp (15 points). (a) What is DNA packing ratio of E. Coli (5 points)? Pleas...
1 answers
Can atoms of some elements can share three pairs of electrons?
Can atoms of some elements can share three pairs of electrons?...
1 answers
In a multiple regression analysis involving 8 independent variables and 165 observations, SST = 650 and...
In a multiple regression analysis involving 8 independent variables and 165 observations, SST = 650 and SSE = 247. The coefficient of determination is equal to what value? (Report your answer as a proportion to 2 decimal places, using conventional rounding rules)...
1 answers
Hi, Could you show me how to solve this APR problem with only using a financial...
Hi, Could you show me how to solve this APR problem with only using a financial calculator please? T hank you in advance f Fundamentals of Corporate Fin... U 7 8 P 13QP140P 15QP 160P170P Chapter 6 Problem 15QP vrov EAR= Effective Annual Rate Step 2 Do Calculate Annual Percentage Rate: APR-m (1 +...
1 answers
When the Cl attacks the epoxide, doesnt it invert the stereochemistry of it? i am a...
when the Cl attacks the epoxide, doesnt it invert the stereochemistry of it? i am a bit confused 11.24 The following equation shows the reaction of trans-2,3-diphenyloxirane with hydrogen chloride in benzene to form 2-chloro-1,2-diphenylethanol. CH, CH + HCI - CH,CH-CHCH, HÓ CI trans-2,3-Dip...
1 answers
Predict why the refractive index of air is slightly higher than the refractive index of a vacuum?
Predict why the refractive index of air is slightly higher than the refractive index of a vacuum?...
1 answers
1. identicy ethical violations that occurred. 2. identify stakeholders and the harm caused by the violation....
1. identicy ethical violations that occurred. 2. identify stakeholders and the harm caused by the violation. 3. identify alternatives. Ethics Case CT19,5 Steve Morgan, controller for Newton Industries, was reviewing production cost reports for the year. One amount in these reports continued to bot...
1 answers
A gaseous system releases 23 J of heat and increases its internal energy by 60 J....
A gaseous system releases 23 J of heat and increases its internal energy by 60 J. Calculate the amount of work associated with this scenario. 83 J of work is done by the system on the surroundings. The system does no work on the surroundings. 37 J of work is done by the system on the surroundings. 8...
1 answers
Need help figuring the unknown and starting these questions. Identify the important (diagnostic) peaks from the...
need help figuring the unknown and starting these questions. Identify the important (diagnostic) peaks from the IR spectrum. corresponds to each peak below. Be sure to also add labels your IR spectrum (write the corresponding bond type next to each peak on the IR spectrum itself) 2. List the ...
1 answers
An insurance company must make payments to a customer of $7 million in one year and...
An insurance company must make payments to a customer of $7 million in one year and $4 million in three years. The yield curve is flat at 8%. a. If it wants to fully fund and immunize its obligation to this customer with a single issue of a zero-coupon bond, what maturity bond must it purchase? (Do ...

-- 0.022972--