NIOS Computer Science: Chapter 9 – Control Statements Part 10

Download PDF of This Page (Size: 465K)

Image of Jump statement

Image of Jump Statement

Image of Jump statement

for (initialization; decision; increment/decrement)




Flowchart with decision box

Flowchart With Decision Box

Flowchart with decision box

The flow diagram indicates that in for loop three operations take place:

(i) Initialization of loop control variable

(ii) Testing of loop control variable

(iii) Update the loop control variable either by incrementing or decrementing.

Operation (i) is used to initialize the value. On the other hand, operation (ii) is used to test whether the condition is true or false.

If the condition is true, the program executes the body of the loop and then the value of loop control variable is updated.

Again it checks the condition and so on. If the condition is true, it gets out of the loop.


for (int i = 0 ; i < 5 ; i + + )

cout << i ;

The output of the above program is

0 1 2 3 4

for (char i = ‘A’; i < ‘E’ ; i + + )

cout < < i ;

The output of the above program is


Jump Statements

The jump statements unconditionally transfer program control within a function.

Image of Jump Statements

Image of Jump Statements

Image of Jump Statements

goto statement

Syntax of goto statement

goto pgr;





pgr is known as label. It is a user defined identifier. After the execution of goto statement, the control transfers to the line after label pgr.

Break statement

Syntax of break statement

The break statement can be used in a switch statement and in any of the loops. It causes program execution to pass to the next statement following the switch or the loop.

Continue statement

The continue statement is used in loops and causes a program to skip the rest of the body of the loop.

The continue statement skips rest of the loop body and starts a new iteration.

exit ( ) function

The execution of a program can be stopped at any point with exit ( ) and a status code can be informed to the calling program.

The general format is exit (code); where code is an integer value.

The code has a value 0 for correct execution. The value of the code varies depending upon the operating system. It requires a process.h header file.

Sign In