TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Wednesday 19 August 2020

Jumping Statement In C++ | Jumping Statement In C++ Example| Jumping Statement In C++ Program | Jumping Statement In C++ Syntax| Jumping Statement In C++ In Hindi

 

Jumping Statement In C++

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. In addition to these jump statements, a standard library function exit () is used to jump out of an entire program.

    1.    Goto statement

    2.    Break statement  

    3.    Continue statement

 

   1.   Goto statement

The C+ + goto declaration is also called a jump declaration. The control to the other part of the program is transferred. It saves to the specified label unconditionally.

Syntax:

goto label;

………….

………….

…………

label:

statement;

…………….

 

Program:

#include<iostream.h>

#include<conio.h>

void main()

{

int n=1;

label:

cout<<”sum of goto is :”<<n<<endl;

n++;

if(n<=5)

goto label;

getch();

}

image of goto statement in c++

Fig: Goto Statement In C++

Output:

Sum of goto is: 1

Sum of goto is: 2

Sum of goto is: 3

Sum of goto is: 4

Sum of goto is: 5

 

     2.   Break statement

This loop control statement is used to terminate the loop. As soon as the break statement is encountered from within a loop, the loop iterations stops there and control returns from the loop immediately to the first statement after the loop.


Syntax:

break;

 

Program:

#include<iostream.h>

#include<conio.h>

void main()

{

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

{

if(i==3)

{

break;

}

cout<<i<<endl;

}

getch();

}

 

image of break statement in c++

Fig: Break Statement In C++

Output:

1

2

 

     3.   Continue statement

The declaration C++ is used for the continuation of the loop. The current program flow continues and the remaining code is omitted at a specified state. If there is an inner loop, only an inner loop continues.

Syntax:

jump-statement;

continue;

 

Program:

#include<iostream.h>

#include<conio.h>

void main()

{

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

{

if(i==3)

{

continue;

}

cout<<i<<endl;

}

getch();

}

 

image of continue statement in c++
Fig: Continue Statement In C++


Output:

1

2

3

4

5

No comments:

Post a Comment