Informatics Notes (Class 11)

CBSE Class 11 Informatics Practices Chapter 5 Control Structure

Rate this post
Class Notes of Chapter 5: Control Structure
Class 11th Informatics Practices

Control Structure


      Topics:

  • Control Structure
  • Sequence Control Structure
  • Selection Control Structure
  • Iteration Control Structure (loops)

Control Structure

For blocking statements for specific number of time, there we use control flow statements. Control flow statements, however, breakup the flow of execution by decision making, looping, and branching, by execute condition expressions for particular blocks of code.

Control flow structure are of three types :

  1. Sequence Control Structure
  2. Selection Control Structure
  3. Iteration Control Structure (loops)

Sequence Control Structure :

Sequence construct means the statements are being executed sequentially. It is a default flow of statement from top to bottom.

Selection Control Structure:

When the execution of the statement(s) depends upon a condition test then it is called selection flow of control. If a condition evaluates to true, one course of action is followed other wise another course of action is followed.

It is achieved by if……else conditionalstatement and switch …….. case conditional statement.

Nested if else

These control structures are used to test for multiple conditions as against the simple if statement which
can be used to test a single condition.:

Syntax:

switch: This selection statement allows us to test the value of an expression with a series of character or integer values. On finding a matching value the control jumps to the statement pertaining to that value and the statement is executed, till the break statement is encountered or the end of switch is reached.

The syntax of the switch statement is as follows:
switch(Variable/Expression)
{
case Value1 :
statements Block 1 ;
break ;
case Value2 :
statements Block 2
break ;
default:
statements Block 3
}
Looping (Iteration):

These statements are used to perform a set of instructions repeatedly while the condition is true.
for ……. Loop Statement :
It is basically used to repaeat block of statement { } for specific number of times.
Syntax
for( initialization; test expression; increment/decrement expression)
{
statements;
}
while loop statement:
The while loop is an entry-controlled loop. It means that the loop condition is tested before executing the loop body. If the loop condition is initially false, for the first iteration, then loop may not execute even once.
The syntax of the while loop is as follows:
Syntax
while(test expression)
{ loop body
}
do…..while loop statement :
Do..While loop is an exit-controlled loop. In the do..while loop, the test occurs at the end of the loop. This ensures that the do..while loop executes the statements included in the loop body at least once.
The syntax of the loop is as follows:
Syntax :
do
{
loop body
}while (test expression);
  1. break : The break is used to break from an enclosing do, while ,for or switch statement.
  2. continue: The continue statement stops the execution of the current iteration and causes control to begin with next iteration.  
  3. return : Return is used to return value from the method

About the author

cbselearners

Leave a Comment

error: Content is protected !!