GreenSalamanderCS's post

Importance of Conditional Statements

Conditional statements are fundamental, as they allow you to run specific blocks of code based on specific conditions, allowing for further control of your program.

 

There are numerous benefits to writing conditional code, including, but not limited to:

> Avoiding repeating code by checking if a condition is met before running it

> Incresaed flexibility & complexity by controlling when & how code is executed

> Handling different scenarios & inputs

> Improve the readability & organization of oyur code

 

There are generally three types of conditional statements you can use:

> Switch/case statements

> If-else statements

> Ternary operators, which only require a single line of code (e.g. "variable == 1 ? true : false;")

More from GreenSalamanderCS