Control Structure
In any programming languages to perform any logical operations of a program like whether the condition statement is true or false. So let us have to know about the control statements or structures in java .
The purpose of control statements is to perform the operations at only once whether condition is true or false (or) To perform the operations repeatedly until the condition is become false.
Most of the programming languages the control structures are classified into 3 types. They are :
- Conditional Statements
- looping / interactive Statements
- Miscellaneous Statements
Control Statements
The control statement is mainly used for performing either the condition is true or false. The operation is once depends upon on the condition evaluation. We have 3 type of conditional statements. They are :
1) if
2) if else
3) switch
Flowchart For Conditional StatementSyntax For if Statement:
if (Test Condition)
{
Executable block of statement's ;
}
statement-x ;
Syntax For if else Statement:
Syntax For if else Statement:
if (Test condition)
{
Executable block of statement's; → 1
}
else
{
Executable block of statement's ; →2
}
statement-x ;
Looping statements
This statements is used for performing some operations repeatedly until condition becomes false.We have 3 types of looping statements.They are :
1) While
A) Initialization part ( where to start )
While (Test Condition)
do
for ( Initialization part; conditional part; operation part )
Looping statements
This statements is used for performing some operations repeatedly until condition becomes false.We have 3 types of looping statements.They are :
1) While
2) Do while
3) For
All the time of dealing with loop statements the programmer must ensure 3 parts. They are :
A) Initialization part ( where to start )
B) Condition part ( how many types to be repeated )
While (Test Condition)
{
Execute Block of Statement's ;
}
Statement-x
Syntax do while:
do
{
Execute
Block of statements)
} While (Test cond )
Statement-x
Syntax for looping:
Syntax for looping:
for ( Initialization part; conditional part; operation part )
{
Execute Block of statements ( s );
}
Statements-x
No comments:
Post a Comment
Thanks for visiting my site..