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
0 Comments