जब a = 4, तो का मान क्या है? नीचे दिए गए कथन में
When a = 4, what is the value of in the given below statement
b = (a > 6 ? 4 : 6);
A
0
B
Error
C
4
D
6
Explanation
Let's break down the given statement:
Statement:
b = (a > 6 ? 4 : 6);
This is a ternary operator statement, which works as follows:
-
The ternary operator is in the form:
condition ? value_if_true : value_if_false -
Condition:
(a > 6)
Whena = 4, the condition(a > 6)evaluates to false (since 4 is not greater than 6). -
Result if false: The ternary operator will return the value after the colon (
:), which is 6.
So, b will be assigned the value 6.
Final Answer:
When a = 4, the value of b will be 6.
The correct answer is:
(D) 6.
Correct Answer: D) 6