Friday, 14 September 2018

Control Statements (Part 1)




Control Statements are the statements which are used to make a group of statements and those groups of statements execute on some certain conditions. These are very useful while taking a decision on the basis of some boolean conditions.



In Java, control statements can be divided into the following three categories:

♣  Sequential Statement (Liner Statement)
♣  Selection Statements (Branching)
♣  Iteration Statements (Loop)


# Sequential Statement (Liner Statement) 

In a program, all statements execute one by one.
Staring from 1st statement to till the last statement.
This is called Sequential Statements.

For Example:-

  


# Selection Statements (Branching)

In Selection/Branching, you just make a group of some similar kinds of statement that together performs some specific kind of job.
We use if, if else to make the group of statements.
It is very useful for decision making on the basis of right or wrong  / true false.

For Example:- if, if else, switch



# Iteration Statements (Loop)

these are some group of statements that executed rapidly till a certain condition is not satisfied.
There are only three kinds of looping/iterative statements till now.
1-for loop
2-while loop (Entry Control loop)
3-do while loop (Exit Control loop)









No comments:

Post a Comment