Computer Science, asked by impossiblebridge, 1 month ago

what are conditional operator in c language?

Answers

Answered by Anonymous
31

Answer:

A conditional operator is a single programming statement, while the 'if-else' statement is a programming block in which statements come under the parenthesis. A conditional operator can also be used for assigning a value to the variable, whereas the 'if-else' statement cannot be used for the assignment purpose.

Answered by Anonymous
25

A conditional operator is a single programming statement, while the 'if-else' statement is a programming block in which statements come under the parenthesis. A conditional operator can also be used for assigning a value to the variable, whereas the 'if-else' statement cannot be used for the assignment purpose.

explanation:

Conditional Operator in C

The above output shows that the value of 'b' variable is 3 because the value of 'a' variable is equal to 5.

As we know that the behavior of conditional operator and 'if-else' is similar but they have some differences. Let's look at their differences.

A conditional operator is a single programming statement, while the 'if-else' statement is a programming block in which statements come under the parenthesis.

A conditional operator can also be used for assigning a value to the variable, whereas the 'if-else' statement cannot be used for the assignment purpose.

It is not useful for executing the statements when the statements are multiple, whereas the 'if-else' statement proves more suitable when executing multiple statements.

The nested ternary operator is more complex and cannot be easily debugged, while the nested 'if-else' statement is easy to read and maintain.

Similar questions