NIOS Computer Science: Chapter 9 – Control Statements Part 2

Download PDF of This Page (Size: 256K)

Image of if else statement

Image of if else Statement

Image of if else statement

Conditional Statements

Sometimes the program needs to be executed depending upon a particular condition.

C++ provides the following statements for implementing the selection control structure.

Image of Control Statements

Image of Control Statements

Image of Control Statements

(1) ‘if’ Statement

The if/else statement executes a block of code if a specified condition is true.

If the condition is false, another block of code can be executed.

The if/else statement is a part of JavaScript's "Conditional" Statements.

Syntax of the ‘if’ statement

If (condition)

{

statement(s);

}

Diagram of If statement

Diagram of if Statement

Diagram of If statement