The jump statements unconditionally transfer program control within a function.
- goto statement
- break statement
- continue statement
The goto statement
goto allows to make jump to another point in the program.
goto allows to make jump to another point in the program.
goto pqr;
pqr: pqr is known as label. It is a user defined identifier. After the execution of goto statement, the control transfers to the line after label pqr.PROGRAM
#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
int x;
abc:
cout<<"Enter Number ";
cin>>x;
goto abc;
getch();
}
OUTPUT
IT SHALL CONTINUE TO UNLIMITED TIME
The break statement
The break statement, when executed in a switch structure, provides an immediate
exit from the switch structure. Similarly, you can use the break statement in
any of the loop. When the break statement executes in a loop, it immediately exits from the loop.
The break statement, when executed in a switch structure, provides an immediate
exit from the switch structure. Similarly, you can use the break statement in
any of the loop. When the break statement executes in a loop, it immediately exits from the loop.
The continue statement
The continue statement is used in loops and causes a program to skip the rest of the body of the loop.
while (condition)
{
Statement 1;
If (condition)
continue;
statement;
}
The continue statement skips rest of the loop body and starts a new iteration.
The continue statement is used in loops and causes a program to skip the rest of the body of the loop.
while (condition)
{
Statement 1;
If (condition)
continue;
statement;
}
The continue statement skips rest of the loop body and starts a new iteration.
The 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.
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.


No comments:
Post a Comment