when use for loop user can assign the value of the variable inside the loop, while checking the condition. but in while loop he has to assign it out side of the loop. like
for loop: for(i=5, n=2; i<=8; i++)
{ n=n+5;
}
while loop: int i=5, n=2;
while(i<=8)
{ n=n+5;
i++;
}
For Lopp;
for Lop is Used For The Specific execution of Our Programm or statements
and we Should initialized,condition and Increment and decrement operator should be declare in for body
e.g
for (intialization;condition;increment or decrement)
while lop:
The While lop use when we dont Know How many time we want execute the set of statemen or statements and in While Body we put only condition.
e.g
while (logical condition)
BY MANSOOR ULLAH
BS comp AWK university mardan pk
Both are programming commands. A do/while loop will execute at least once. A while loop may not execute at all.
the counter variable cannot be initialized in while loop before entering into the block.
Do while and Do until are interchangeable, and they take the opposite condition. Do While executed the body of the loop while (condition=true), and Do until executes body of loop until (condition=true). For example, if I was doing a Loop to say, while the check box is checked, display a message box (Never do this btw, it's just an example) I could either say Do While (MyCheckBox.Checked = True) Loop or Do Until (MyCheckBox.Checked <> True) Loop
Easy: if-else is not a loop; while, for and do-while are loops.if-else just run once, but do-while run many times.
Well 'while' goes like this: while (condition) statement 'for': for (initialize; condition; after-each-loop) statement
No difference.
A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop
You mean PL/SQL? Well, they are different things, read the manual for details.
If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed
In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.
UNIX has no bearing on the C language; it is cross-platform. There is no select/case in C, you probably meant switch/case. However, a switch/case is a conditional jump while a nested loop is a loop within a loop. Besides the C language they have nothing in common with each other.
the main difference b/w do and while loops is that do loop will run atleast once even if condition is not satisfied but while loop will not execute even once if condition is not satisfied . this is bcoz in do loop condition is checked after one execution but in while condition is prechecked.