Saturday, 19 May 2012

Looping in c language and use of for loop

Looping is a way through which we execute similarly types of statement again and again.

Example : In car racing racer have same track to practice. So they use it again and again for practice means make a definite loop which has a start point and  a end point and how many times they want to practice it.

Example :  We have a mobile on which we set alarm. Alarm starts at fix time and stop also on fix time. Between start and end time alarm tune always same. That's  why  alarm tune sounded at that interval.

Any loop has a start point                      --------> called  initialization in programming.
Study last post about looping
 Initialization is a process through which we start loop from a certain point.

Example : we need to count ten bats. We can start our counting from any number
  1 or 10 or -10 or any other so this is called our start point. Same as loop has a start point.

Any loop has a end point                      --------> called  condition in programming.

Condition is end point of loop where we expect to stop.

Example : As after starting our counting we stop at any definite point.

  if  starts from 1 we stop at 10.
  if  starts from 10 we stop at 19.
  same as if starts from -10 we stop at -1.
  this is called end condition of loop.
  
Travel between start and end point   ----> called increment and decrement  of loop

As we starts from 1  then we go to 2 then 3 and so on...means we are incrementing value
Similarly if we starts from -10 we go -9 then -8 and so on...means we are decrementing value.

loop's life cycle
   


 As from above flow we can learn that

  1. At first step loop goes to initialization part.
  2. At second step loop check condition.
  3. At third step loop perform increment and decrement task.
  4. If condition comes false loop quite and comes outside


Read latest blog
 

No comments:

Post a Comment