Example :Write a program in C to print odd and even number using 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 :Write a program in C to display the concept of 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 :Write a program in C to display the concept of 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

 1,081 total views,  1 views today

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.