Question
Consider the following C++ code: Â Â int a =
5; Â Â int b = 10; Â Â if (a > 0 && b < 10) { Â Â Â Â a = a + b; Â Â } else if (a == 5 || b == 10) { Â Â Â Â a = b - a; Â Â } else { Â Â Â Â a = 0; Â Â } Â Â // What is the value of 'a' after the execution of this code?Solution
Let's trace the execution with the initial values: a = 5, b = 10.   1. if (a > 0 && b < 10):     (a > 0) evaluates to (5 > 0), which is true.     (b < 10) evaluates to (10 < 10), which is false.     The entire condition true && false evaluates to false.     Therefore, the code block inside this if statement is skipped.   2. else if (a == 5 || b == 10):     (a == 5) evaluates to (5 == 5), which is true.     (b == 10) evaluates to (10 == 10), which is true.     The entire condition true || true evaluates to true.     Therefore, the code block inside this else if statement is executed.   3. Inside the else if block:     a = b - a;     Substitute the current values: a = 10 - 5;     a becomes 5.   Since an else if block was executed, the final else block is skipped.   The final value of a is 5.
He knew the situation was difficult, but he decided to _______ and tackle the problem head-on.
- Select the most appropriate option to fill in the blanks.
She will _____________ her research at the conference before receiving a _____________ fr... In each of the following sentences there is one blank space. Find out which word can be filled up in the blanks in sentence in the same sequence to mak...
Fill in the blank with the most appropriate word.
Ramesh would not have been successful in the project but …….my help.Â
Although it was a beautiful day with a clear blue sky, the runner feeling (A) / tired and sore, yet with the determination to reach the finish line, de...
Sitaram Swain, winner of the Emerging Artist of the year Award 2017, tells us how common objects …….him to deal ….. bigger issues.
The town ________ both National Hunt racing and Flat racing.
The government’s modified scheme ____________ that legal heirs of farmers who have committed suicide on being unable to pay the loan ______________ f...
Choose the correct option to fill blank 1.
The ________ between the two nations resulted in years of peaceful relations.