Loop
Suppose you’re a class teacher and your college organized a tour for somewhere so you have assigned a task to fill up tour fee form. Total 200 hundred students in your class, in this situation you need to reach each student seat and collect fees. If we analysis from computer point of view for this scenario then you need to take total 200 step for achieve this.
This was real life an example which creates a basic idea of repetitive task. This type of task needs some automatic process which minimizes our effort then loop is your solution. Following are some example of task where you need loop.
- Printing all numbers between 1 to 100
- Printing your name a number of times
- Accessing some continuous item like arrays
C language gives you three types of loops to accomplished repetitive task.
- While
- For
- Do-while
While Loop
Syntax: