Ternary operator is an operator which can be used in place of an if else condition when both if and else part has only one line inside them. Lets look at the syntax of ternary operator in C language and understand ternary operators with example.
Syntax of Ternary Operators in C
Here is the syntax of ternary operator along with its if else equivalent code.
Here is the syntax of ternary operator along with its if else equivalent code.
(some condition to check) ? (if condition is true) : (if condition is false); /* if(some condition to check){ //if condition is true }else{ //if condition is fasle } */
Ternary operator has three operands (as the name ternary suggests).
- First is the condition which needs to be checked for true or false.
- After the condition, there is a question mark ( ? ) and after the question mark comes the statement which is executed if the condition is true i.e the if part of if else.
- At last there is a colon ( : ) and after colon comes the statement which is executed if the condition is false i.e the else part of if else.
Hello There,
I learnt so much in such little time about C Programming Tutorial Even a toddler could become smart reading of your amazing articles.
I just wanted to know How can we use WebSQL ?
I look forward to see your next updates.
Kind Regards,
Priya