🔸Conditional Statements
if statement
if (condition) do this
if (condition) do this
else if (condition2)
do this
else if (condition2)
do this
else
else
do
do
example:
Conditional operator (ternary statement)
condition ? expression1 : expression2
example:
switch statement
switch (expression) {
case value 1: do this break;
case value 2: do this
break;
case value n: do this break;
default: do this break; }
example:
Go To
goes to the given part of the program and starts execution from there should never need to use the goto statement in C.
example:
using 'goto' is a bad idea for making conditional statements, try to use it only when you want to break out of nested loops or statements ( just to make the code more clean and readable )
Last updated