NIOS Computer Science: Chapter 9 – Control Statements Part 1

Download PDF of This Page (Size: 275K)

Image of control Statements

Image of Control Statements

Image of control Statements

Introduction

The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program.

Control statements enable us to specify the flow of program control; ie, the order in which the instructions in a program must be executed.

They make it possible to make decisions, to perform tasks repeatedly or to jump from one section of code to another.

The statements which specify the order of execution of statements are called control flow statements.

There are many control flow statements provided in C++ that will be discussed in this lesson.

Objectives

Image of Control Statements objectives

Image of Control Statements Objectives

Image of Control Statements objectives

Statements

Statements are the instructions given to the computer to perform any kind of action. Action may be in the form of data movement, decision making etc. Statements form the smallest executable unit within a C++ program. Statements are always terminated by semicolon.

Compound Statement

A compound statement is a grouping of statements in which each individual statement ends with a semi-colon.

The group of statements is called block. Compound statements are enclosed between the pair of braces ( { } ).

The opening brace ( { ) signifies the beginning and closing brace ( } ) signifies the end of the block.

Null Statement

Writing only a semicolon indicates a null statement.

Thus ‘;’ is a null or empty statement.

This is quite useful when the syntax of the language needs to specify a statement but the logic of the program does not need any statement.

This statement is generally used in for and while looping statements.