IGCSE Computer Science Paper-1: Specimen Questions with Answers 54 - 54 of 164

Doorsteptutor material for Bank-PO is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of Bank-PO.

Question 54

Edit

Appeared in Year: 2013

Describe in Detail

Essay▾

What are the different types of loop structure used in a typical programming language?

Explanation

  • A loop in programming is the combination of two parts, a body of a loop and a control statement.
  • A loop is mainly classified into two types Entry Controlled Loop and Exit Controlled Loop.
  • Entry controlled loop: A condition is checked before executing the body of a loop and is also called as a pre-checking loop.
  • Exit controlled loop: A condition is checked after executing the body of a loop and is also called as a post-checking loop.

Three types of loop constructs are provided by ‘C’ Programming language:

The while loop: In while loop, a condition is evaluated before processing a body of the loop. The body of a loop is executed if and only if the condition is true.

Format of while Loop

  1. While ( condition ) {
  2. Statements;
  3. }

Do-While loop: Here the condition is always executed after the body of the loop and therefore it is also known as an exit-controlled loop. Here the body of the loop can be executed even if the condition is false.

Format of Do-While Loop

  1. do {
  2. Statements
  3. } while ( expression );

For loop: In this loop the initial value is performed only once. The condition is a Boolean expression. The loop stops when false is returned.

Example

  1. for ( x =0, y =num; x < y; i ++, y -- ) {
  2. Statements;
  3. }

🎯 Select Paper 📂

Developed by: