What is Loop?
A method or mechanism through which a statement or a set of statements of program can be executed again and again (repeat) that is called loop. The body of loop can be executed again and again for a given number of times.Loop Statements
Loop statement are used to execute a statement or a set of statements again and again. Loops are the most important function of any programming language. Loop Statement is also known as iterative structure or repetitive structure. When we need to use loop we must need to tell the system starting number and ending number to execute yhe loop statement otherwise it may give error or infinite loop.Types of Loop Statements in C
In C/C++ language there are three types of loop statements.- 'while' loop
- 'do-while' loop
- 'for' loop
Control Variable
Any variable which is used in loop statement to control the number execution or flow in the loop that is known as loop control variable. Usually, we initialize variable at before the body of loop because it will be see where the loop statement will be execute first.'while' Loop
'while' loop is a conditional loop structure in programming language. It is used to execute a statement or a set of statements as long as the given condition remains true. This loop structure is used when the programmer does not know in advance the number of repetition of loop.The general syntax of 'while' structure is as follows:
while (condition)
statement ;
next_statement ;
No comments:
Post a Comment
Thanks For Visiting Here...!! I will Reply you as soon as possible.