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.
Syntax:
while (test loop counter using condition/expression) { statements; 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) while(i>=10 && j<=15) while(j>10 &&(b<20 || C>20))
- Note that while(test condition) does not have ";" at the end.
No comments:
Post a Comment