Jump Statements In C Programming

Share Your Love

Jump statements are the statements when encountered the control shifts from one part to another part of the program. The different types of jump statement are:

  • Break
  • Continue
  • Goto

Let us discuss them one by one.

Break Statement:

A break statement is a statement that terminates the block when called and continues with the rest of the program. The break statement is initialised with the break keyword. The break statement is most frequently used in switch case or within is loop else it results in a compile-time error.

Example of Break Statement:

#include<stdio.h>
int main()
{
	int a=1;
	while(a!=10)
	{
		if(a==5)
		{
			printf("\nBreak encountered");
			break;
		}
		else
		printf("\nBreak not encountered");
		a++;
	}
	printf("\nBlock encountered after break statement");
	return 0;
}

Output:

Continue Statement:

The continue statement makes the control move to the next iteration without actually terminating the block. It is also used in loops and is initialized with the continue keyword.

Example Of Continue Statement:

#include<stdio.h>
int main()
{
	int a=1;
	while(a!=10)
	{
		a++;
		if(a==5)
		{
			printf("\nContinue encountered");
			continue;
		}
		else
		printf("\ncontinue not encountered");	
	}
	return 0;
}

Output Of Continue Statement:

KdwCi65uPFxIyrUcSLUm5wH wgdPZNW1J uB8BEtB2rX DIsM593EPhaGF nF8syXyCTjIwznah3RmkDvPILiV32aJmBDSAen1WK8Rw2Nzu9efuJvq

Goto Statement:

The goto is a decision-making statement, when encountered it points to the statement which is initialized in the label: statement. It is depicted with the goto keyword.

Syntax Of Goto Statement:

goto label;
... .. 
...... 
.. ...
label: statement;

goto Statement Example:

#include<stdio.h>
int main()
{
int a=30,b=20;
if(a>b)
{
goto label;
}		
label:
printf("Goto executed");
return 0;
}

Output:

Kip1I R1Vv0IKXDzCK3tqIEYUgIeTuGpaoFSCaR M9ZshcFVLQZkpy RtAjHHZ16h2CEqnKKbAq4wzi4fI6Ke0 iBkoPZFq6zU4lurjmi9vpJlDG vGr0TgziH7pvQM9jZCFQ

Here we come to the end of the topic on jump statements in C, hope we have cleared all your doubts.

Please write comments or WhatsApp if you find anything incorrect, or you want to share more information about the topic discussed above.

Share Your Love
Avatar photo
Soham Malakar

Hello my name is Soham Malakar am currently pursuing BCA

Coding is one of my favorite hobbies.
I love to code and an enthusiast to learn different types of programming languages.
I love to get intoxicated in the world of technology and video games.
A quick learner possessing better results.

Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter