IEO Level 2- English Olympiad (SOF) Class 9 Coaching Programs
⏳ 🎯 Online Tests (2 Tests [50 Questions Each]): NTA Pattern, Analytics & Explanations
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
🎓 Study Material (303 Notes): 2024-2025 Syllabus
Click Here to View & Get Complete Material
Rs. 450.00
3 Year Validity (Multiple Devices)
🎯 250 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
Computer Science: Control Statements: Jump Statement: Goto Statement
for (initialization; decision; increment⟋decrement)
{
Statement (s) .
}
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.
Example
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
A B C D
Jump Statements
The jump statements unconditionally transfer program control within a function.
Goto Statement
Syntax of goto statement
goto pgr;
|
|
|
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.