While Loop
Yes
another cool loop statement name "While Loop". A "While"
Loop is used to repeat a specific block of code an unknown number of times,
until a condition is met. That’s the simple definition of while loop.
Easy it is, isn't It.???
So what while loop will do -- A while loop statement repeatedly executes a
target statement as long as a given condition is true.
And what is the difference between the while and for loop???
For loop: for loop provides a concise way of writing the loop structure. Unlike
a while loop, a for statement consumes the initialization, condition and
increment/decrement in one line thereby providing a shorter, easy to debug
structure of looping.
Here
it is a beautiful pic of my program and its output. In this program I have
defined variable "a" and assigned it value "0" and in while loop
condition (a<=8) is written, so by this it will writ value of an up to
number 8 because the condition is a<=8 and at last the variable "a" will increment
by +1.