Comparison ya difference between do while , while and for loop (2 points each)
Answers
Answered by
2
Do while loop :-
1) It is an exit control loop i.e. it executes body of the loop before checking condition.
2) Syntax (in java) :-
do
{
Statements;
}
while (condition);
While loop :-
1) it is an entry control loop i.e. it checks conditions before executing the body.
2) Syntax( in java) :-
while (conditions)
{
conditions;
}
FOR LOOP :-
1) It is an entry control loop i.e. it checks condition before executing loop
2) Syntax(in java) :-
for (declaration;condition;increment/decrement)
{
conditions;
}
HOPE IT HELPS!!!!
1) It is an exit control loop i.e. it executes body of the loop before checking condition.
2) Syntax (in java) :-
do
{
Statements;
}
while (condition);
While loop :-
1) it is an entry control loop i.e. it checks conditions before executing the body.
2) Syntax( in java) :-
while (conditions)
{
conditions;
}
FOR LOOP :-
1) It is an entry control loop i.e. it checks condition before executing loop
2) Syntax(in java) :-
for (declaration;condition;increment/decrement)
{
conditions;
}
HOPE IT HELPS!!!!
Similar questions