Write the following if...else statement using the conditional operators
If (x == 100)
a = "x is 100"
else
a = "x is not 100"
Answers
Answered by
5
Explanation:
Syntax : (Condition? true_value: false_value);
(x== 100 ? "x is 100" : "x is not 100");
Answered by
1
a=x==100?"x is 100":"x is not 100"; is the answer for the above question
Explanation:
- The conditional or ternary operator is an operator that is used to check the condition. It has three phases which are as follows:-
- The first phase is used to check the condition.
- The second phase is executed if the condition will true.
- The third phase is executed if the condition is false.
- One variable is also used to hold the value of the condition. The above question has an if and else statement which checks the value of an x variable to be equal to 100 or not.
- So the above expression also holds the condition to check the value to be equal to 100 or not.
Learn More:
- Conditional operator: https://brainly.in/question/10641825
Similar questions
Physics,
5 months ago
India Languages,
5 months ago
Math,
10 months ago
Chemistry,
1 year ago
English,
1 year ago