What is ternary operator in c?
Today is my exam
wish me good luck
Anonymous:
hello
Answers
Answered by
4
Ternary operator is used as a conditional operator.
They are easier to use than if else if
Answered by
8
Short notes on Ternary Operator:
(i) Ternary operator works like if-then-else statement.
(ii) It is also called as conditional operator.
(iii) It requires three arguments. If the expression is true, then it evaluates true then true statement is executed else false statement is executed.
Syntax:
condition?true?false
Example:
int a = 10, b = 15;
a > b ? printf("a is greater") : printf("b is greater");
Advantages:
(i) code redundancy
(ii) Improves the performance
************** Wish U All The Very Best ***********************
Similar questions
Computer Science,
7 months ago
Math,
7 months ago
Social Sciences,
7 months ago
Math,
1 year ago
Math,
1 year ago
Chemistry,
1 year ago