Electronics and Communication Engineering - Microprocessors - Discussion

Discussion Forum : Microprocessors - Section 1 (Q.No. 47)
47.
Let JCOKE = 98 and LPEPSI = 42 Consider the statement

IF (JCOKE - 3 * LPEPSI) 5, 6, 7
5 JCOKE = JCOKE + 5
6 JCOKE = JCOKE + 8
7 JCOKE = JCOKE + 11

The value of JCOKE after the execution of above statement will be
103
106
109
none of the above
Answer: Option
Explanation:

Since (J COKE - 3 x L PEPSI) is negative, statement 5 is executed and the result is 98 + 5 = 103.

Discussion:
13 comments Page 1 of 2.

Dhanush said:   4 years ago
Arithmetic if has the syntax IF (Expression) negative, zero, positive, which means.

Execute negative, if the expression results in negative.
Execute zero, if the expression results in zero.
Execute positive if it results in positive.

Dhanush said:   4 years ago
Any non-zero number in the 'if' statement is evaluated as 'True'.

Hence, if (-28) is true and the statement associated with the if statement is executed (here since there is no brackets only line 5 is under the control of the if statement and will get executed and line 6 and 7 will not get executed.

Sanskar Gupta said:   4 years ago
Please explain the concept clearly. What is the logic behind the digit 5 6 7?

Jeshnavi said:   4 years ago
But why 5 should be executed. Why not 8 & 11 are executed. Can any explain this?

Anju said:   5 years ago
Please explain in detail.

Puja said:   7 years ago
Please, anyone, explain the answer with the logic.

Kali said:   8 years ago
I am not able to understand. What is the logic behind this?

Please explain.

Swathipriya said:   10 years ago
Normally we will have only 2 cases for IF. Here are options. One is for negative what about remaining two?

Krisha said:   1 decade ago
98 - (3*42) = 98 - 126 = -28 according to operator priority. But what is the logic behind 103.

Goldy said:   1 decade ago
Please explain in details. Thank you in advance.


Post your comments here:

Your comments will be displayed after verification.