Computer Science, asked by ishan5454, 11 months ago

write a note on jump statements in C plus plus​

Answers

Answered by rohirahut
1

Answer:

Jump Statements in c++ or Goto statement. Jump statements are used to alter the flow of control unconditionally. That is, jump statements transfer the program control within a function unconditionally. The jump statements defined in C++ are break, continue, goto and return.

mark me as brainlist pls

Answered by vivektripathi1234
1

Answer:

Jump Statements in C++

Jump statements are used to interrupt the normal flow of program.

Types of Jump Statements

  • Break
  • Continue
  • GoTo

Break Statement

The break statement is used inside loop or switch statement. When compiler finds the break statement inside a loop, compiler will abort the loop and continue to execute statements followed by loop.

Example of break statement

#include<iostream.h>

void main()

{

int a=1;

while(a<=10)

{

if(a==5)

break;

cout << "\nStatement " << a;

a++;

}

cout << "\nEnd of Program.";

}

Output :

Statement 1

Statement 2

Statement 3

Statement 4

End of Program.

Continue Statement

The continue statement is also used inside loop. When compiler finds the break statement inside a loop, compiler will skip all the followling statements in the loop and resume the loop.

Example of continue statement

#include<iostream.h>

void main()

{

int a=0;

while(a<10)

{

a++;

if(a==5)

continue;

cout << "\nStatement " << a;

}

cout << "\nEnd of Program.";

}

Output :

Statement 1

Statement 2

Statemnet 3

Statement 4

Statement 6

Statement 7

Statement 8

Statement 9

Statement 10

End of Program.

Goto Statement

The goto statement is a jump statement which jumps from one point to another point within a function.

Syntax of goto statement

goto label;

- - - - - - - - - -

- - - - - - - - - -

label:

- - - - - - - - - -

- - - - - - - - - -

In the above syntax, label is an identifier. When, the control of program reaches to goto statement, the control of the program will jump to the label: and executes the code after it.

Example of goto statement

#include<iostream.h>

void main()

{

cout << "\nStatement 1.";

cout << "\nStatement 2.";

cout << "\nStatement 3.";

goto last;

cout << "\nStatement 4.";

cout << "\nStatement 5.";

last:

cout << "\nEnd of Program.";

}

Output :

Statement 1.

Statement 2.

Statement 3.

End of Program.

Hope its help you

Explanation:

My answer mark as brainliest

Similar questions