quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif while

The while loop executes as long as an < expression > evaluates as true. This is the same as in any other programming language.

   

space.gif

There are two forms of while statement

   

space.gif

  • while
  • do while
   

space.gif

Syntax : while

   

space.gif

while (condition) statement
   

space.gif

   

space.gif

Syntax : do while

   

space.gif

do {
  statement
}  while (condition);
   

space.gif

   

space.gif

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : do-while
   

space.gif


  1 program while_statement {
  2   integer i = 0;
  3   integer j = 10;
  4   // while example
  5   while (i < 5) {
  6    printf("Value of i %0d\n",i);
  7    i ++;
  8   }
  9   // do - while example
 10   do {
 11    printf("Value of j %0d\n", j);
 12    j --;
 13   } while (j > 5);
 14 }
You could download file while_statement.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : do-while
   

space.gif

 Value of i 0
 Value of i 1
 Value of i 2
 Value of i 3
 Value of i 4
 Value of j 10
 Value of j 9
 Value of j 8
 Value of j 7
 Value of j 6
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com