Conditional Statements - cradules/cs50 GitHub Wiki
Conditional Statements
-
Conditional expressions allow your programs to make decisions and take different forks in the road, depending on the values of variables of user input.
-
C provides few different ways to implement conditionals expressions (also know as branches) in your programs, some of witch likely look familiar.
-
if {boolean-expresion}
{
}
-
if the Boolean expression evaluates to true, all line of the code between the curly braces will execute in order from top-to-bottom
-
if the boolean-expressions evaluates to false, those line of codes will not execute.
-
if {boolean-expresion}
{
}
else
{
}
-
-
If the boolean-expression evaluates to true, all lines of code between the first set of curly braces will execute in order from top-to-bottom
-
If boolean-expresion evaluates to false, all line of code between the second set of curly braces will execute in order from top-to-bottom