Looping Statements or Iterative Statements These are used to run the set of statements repeatedly. Here the statements run repeatedly until the given condition is false. We need to write a proper condition so that the loop runs finite number of times. Types of loops: while do-while for foreach 1)while loop: Here the loop executes until the given condition is false. The Initialization / declaration can be done at anywhere before the loop. Syntax: while(condition){ //statements which are needed to be execute Increment/Decrement; } 2)do-while loop: Here the statements are executes atleast one time , even the given condition is false. It is exit control loop whereas for,while are entry control loops. Syntax: do{ //statements which are needed to be execute }while(conditon); 3)for loop: Here the number of Iterations can be known. Here the initialization , Declaration , Condition , Increment / Decrement are present a single place. We can place multiple Declarations , Increments / Decreme...
Comments
Post a Comment