Computer Applications
Define the following with their constructs:
(a) Entry controlled loop
(b) Exit controlled loop
Java Iterative Stmts
144 Likes
Answer
(a) Entry controlled loop
An entry-controlled loop checks the condition at the time of entry. Only if the condition is true, the program control enters the body of the loop. for and while loops are entry-controlled loops.
(b) Exit controlled loop
An exit-controlled loop checks the condition after executing its body. If the condition is true, loop will perform the next iteration otherwise program control will move out of the loop. do-while loop is an exit-controlled loop.
Answered By
84 Likes
Related Questions
Rewrite the following program using while loop:
import java.util.*; class Number { public static void main(String args[]) { int n,r; Scanner in = new Scanner(System.in); System.out.println("Enter a number"); n=in.nextInt(); do { r=n%10; n=n/10; System.out.println(r); } while(n!=0); } }
What is for loop? What are the parameters used in for loop?
Write down the syntax of:
(a) do - while
(b) while loop
What is the purpose of using break statement in a program?