control statements

Control statements are used to decide the program execution order based on some conditions.

It is also called decision making statements.

Example

Let’s write a program for dividing two integers.

But, if we divide a number by 0, program execution will stop as its undefined behavior.

Here, we must decide and restrict the execution of dividing code, if the divisor is zero.

Dividing a number by zero is undefined.


So, the execution order will be,

If divisor is zero

     Don’t execute division statement.

Else

     Execute it.


Let’s discuss about it one by one with examples.


Topics You Might Like