C – If Else , Switch, Decision Making – POFTUT

C – If Else , Switch, Decision Making

[rps-include post=6557]

Conditions or Decisions making is one of the most important aspect of programming languages. Actual programming logic is implemented in the decisions. According to decisions the application will be branched and expected results or operations will be accomplished. There are 3 main decision making mechanisms. We will look in details below.

If

The syntax of if is like below in C programming language.

with if(boolean_expression) if boolean_expression is true code block of if which is specified as statements_to_execute is executed. If boolean_expression is not true statement_to_execute code block is skipped without executing. Let’s make an example to make things more clear and understandable.

If Else

If else is similar to the if . Else is executed if if is not executed because of boolean_expression .

If Else if

Up to now we have only evaluated two condition with if and else . But in real world there will be more than two conditions to check. In this situation if ... else if ... can be used.

Switch Case

Switch case is alternative to if statement . Their functionality is very similar. Expressions is evaluated for each case statement. Matched case statements will be processed. For a single expressions more than one case conditions can be matched.

[rps-include post=6557]

LEARN MORE  Javascript Decision Making with If-Else

Leave a Reply

Your email address will not be published. Required fields are marked *