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.
A woman borrows Rs. 80,000 from a bank at 8% per annum. She invests Rs. 30,000 of it in a business at 12% per annum and the rest at 10% per annum. Calcu...
The difference between the compound interest and simple interest on a certain sum for 2 years at 10% per annum is Rs. 72. Find the simple interest on th...
A invests Rs 6000 in a business for the whole year. B joins him later with an investment of Rs 8000. At the end of the year, the profit is divided betwe...
- A sum of money placed at simple interest becomes Rs. 14,400 in 4 years and Rs. 18,000 in 7 years. What is the initial amount invested?
Ankita invested Rs. 1800 at an annual interest rate of (a + 5)%, and she earned a total interest of Rs. 1404 after three years. Now, if she decides to i...
- Rohit invested Rs. 18,000 at simple interest of 6% p.a. If he kept withdrawing Rs. 3,000 after every one year, then find the total interest earned by Rohit...
A sum of money lent at compound interest at the rate of 20% per annum is paid back in three equal annual installments of Rs.864. Find the sum of money?
The difference between compound interest and simple interest at rate of 18% per annum for 2 years is Rs. 486. Find the simple interest obtained on same ...
The difference between compound interest and simple interest on a sum of Rs 8,000 for 2 years at the same rate is Rs 20. Find the rate of interest per a...
A certain amount earns simple interest of Rs. 1360 after 4 years. Had the interest been 5% more, how much more interest would it have earned?