A Loop is used to execute a block of code again and again for a certain number of times. for example, you can use a loop to print the first N natural numbers. A conditional control structure ( if-else, switch, conditional operator) allows us to execute a set of instructions in one scenario and another set of instructions in a different scenario.
A conditional operator ( also called a “Ternary Operator” ) functions in the same way as an if-else statement.
The syntax looks like this (condition to be tested) ? statement1 : statement2 ;
When the condition to be tested evaluates to True, statement 1 is executed.
Else statement 2 is executed.
Its the same as…
if( condition ) statement1 ;
else statement2 ;
I hope this made the point clear !!
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
A Loop is used to execute a block of code again and again for a certain number of times. for example, you can use a loop to print the first N natural numbers. A conditional control structure ( if-else, switch, conditional operator) allows us to execute a set of instructions in one scenario and another set of instructions in a different scenario.
A conditional operator ( also called a “Ternary Operator” ) functions in the same way as an if-else statement.
The syntax looks like this (condition to be tested) ? statement1 : statement2 ;
When the condition to be tested evaluates to True, statement 1 is executed.
Else statement 2 is executed.
Its the same as…
I hope this made the point clear !!