CASE CONTROL STRUCTURES:
1. continue statement program:
// prg to illustrate continue statement
#include<stdio.h>
void main()
{
int i=1,n,s;
printf("enter n value:");
scanf("%d",&n);
printf("enter skip value:");
scanf("%d",&s);
for( i=1; i <= n ; i++)
{
if (i == s)
{
printf("\nSkipping %d from display using continue statement \n",i);
continue;
}
printf("%d\n",i);
}
}
output:
2. break statement program:
// prg to illustrate break statement
#include<stdio.h>
void main()
{
int i=1,n,s;
printf("enter n value:");
scanf("%d",&n);
printf("enter skip value:");
scanf("%d",&s);
for( i=1; i <= n ; i++)
{
if (i == s)
{
printf("\nSkipping %d from display using continue statement \n",i);
break;
}
printf("%d\n",i);
}
}
output:
1. continue statement program:
// prg to illustrate continue statement
#include<stdio.h>
void main()
{
int i=1,n,s;
printf("enter n value:");
scanf("%d",&n);
printf("enter skip value:");
scanf("%d",&s);
for( i=1; i <= n ; i++)
{
if (i == s)
{
printf("\nSkipping %d from display using continue statement \n",i);
continue;
}
printf("%d\n",i);
}
}
output:
2. break statement program:
// prg to illustrate break statement
#include<stdio.h>
void main()
{
int i=1,n,s;
printf("enter n value:");
scanf("%d",&n);
printf("enter skip value:");
scanf("%d",&s);
for( i=1; i <= n ; i++)
{
if (i == s)
{
printf("\nSkipping %d from display using continue statement \n",i);
break;
}
printf("%d\n",i);
}
}
output:
No comments:
Post a Comment