Example : A program in C to print odd and even numbers using the goto statement.
#include<stdio.h>
#include<conio.h>
void main()
{
	int num;
	clrscr();
	printf("Enter a number: ");
	scanf("%d",&num);
	if(num%2==0)
		goto even;
	else
		goto odd;
	    even:
		printf("\nThe given number is Even");
		goto stop;
	    odd:
		printf("The given number is Odd");
		goto stop;		
	    stop:
		
	getch();
}
Example : A Jumping Statement Examples in C to display the concept of a continue statement.
#include<stdio.h>
#include<conio.h>
void main()
{
	int i;
	clrscr();
	for (i=1;i<=10;i++)
        {
          if(i==4)
            {
	      continue;
            } 
          printf("%d ",i);
        }
	getch();
}
Output : 1 2 3 5 6 7 8 9 10
Example : A program in C to display the concept of a break statement.
#include<stdio.h>
#include<conio.h>
void main()
{
	int i;
	clrscr();
	for(i=1;i<=10;i++)
        {
          if(i==4)
            {
	      	break;
            } 
          printf("%d ",i);
        }
	getch();
}
Output : 1 2 3

Link for more about Jumping statements in C

Loading

Categories: C

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.