Ask a Teacher
What is mean by entry flow and exit flow? |
Did you mean entry controlled loop and exit controlled loop then the answer is: Entry controlled loop: The while loop is an entry-controlled loop. The syntax of a while loop is: while(expression) loop-body where the loop-body may contain a single statement, a compound statement or an empty statement.The condition is evaluated, and if the condition is true, the code within the block is executed. This repeats until the condition becomes false. Because while loop checks the condition before the block is executed, the control structure is often also known as a pre-test loop.Loop control variable should be initialised before the loop begins as an uninitialised variable can be used in an expression. The loop variable should be updated inside the body of the while. int x = 0; while (x < 5) { printf ("x = %d\n", x); x++; } first checks whether x is less than 5, which it is, so then the {loop body} is entered, where the printf function is run and x is incremented by 1. After completing all the statements in the loop body, the condition, (x < 5), is checked again, and the loop is executed again, this process repeating until the variable x has the value 5. Exit controlled loop: The do-while loop is an exit-controlled loop. The syntax of a do-while loop is: do { statement; }while(test-expression); while loop, is a control flow statement that allows code to be executed once based on a given Boolean condition.The do while construct consists of a process symbol and a condition. First, the code within the block is executed, and then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Because do while loops check the condition after the block is executed, the control structure is often also known as a post-test loop. Contrast with the while loop, which tests the condition before the code within the block is executed. |