-- conditional statement
if (a==0)
ans = 1
else
ans = 2;
-- ternary operator
ans = a == 0 ? 1 : 2 ;
Ternary Operator is a compact way of writing conditional expression and also achieve the same result.
It is used for shortening the if else statement and makes the code cleaner.