While Loop in C

While Loops is one of the loops that is used in C program.

While Loops:

  • While Loop is used when we know in prior that how many time the loop has to be executed.
  • E.g when we want to calculate simple interest of five different persons.


while (test loop counter using condition/expression)

do this;
/* This portion usually includes logic of program or 
anything that has to be executed repeatedly*/ 

More about while loops:

  • Test condition should be such that it should eventually become false, otherwise the loop would be executed FOREVER...indefinitely.
  • Condition being tested may use relational or logical operator.
while(i>=10 && j<=15)
while(j>10 &&(b<20 || C>20))
  • Note that while(test condition) does not have ";" at the end.

See the following video:

No comments:

Post a Comment