

InterviewSolution
Saved Bookmarks
1. |
What is loop and its types.daigram of each type and syntax |
Answer» A\xa0Loop\xa0executes the sequence of statements many times until the stated condition becomes false. A loop consists of two parts, a body of a loop and a control statement. The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. The purpose of the loop is to repeat the same code a number of times.\t\tA while loop is the most straightforward looping structure. Syntax of while loop in C programming language is as follows:\t<pre>while (condition) { statements;}</pre>\t\t\tA do...while loop in C is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit-controlled loop.\tSyntax of do...while loop in C programming language is as follows:\t<pre> do { statements} while (expression);</pre>\t\t\tA for loop is a more efficient loop structure in \'C\' programming. The general structure of for loop syntax in C is as follows:\t<pre>for (initial value; condition; incrementation or decrementation ) { statements;}</pre>\t | |