If I want to print numbers from 1 to 10 with the exception of 2 how???
continue :When continue is encountered inside any loop, control automatically passes to the beginning of the loop.
A continue is usually associated with an if.
Example
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<=10;i++)
{
if(i==2)
continue;
printf("%d\n",i);
}
getch();
return 0;
}
output:
0
1
3
4
5
6
7
8
9
10
//program to print odd numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<=10;i++)
{
if(i==2)
continue;
printf("%d\n",i);
}
getch();
return 0;
}
output:
1
3
5
7
9
continue :When continue is encountered inside any loop, control automatically passes to the beginning of the loop.
A continue is usually associated with an if.
Example
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<=10;i++)
{
if(i==2)
continue;
printf("%d\n",i);
}
getch();
return 0;
}
output:
0
1
3
4
5
6
7
8
9
10
//program to print odd numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<=10;i++)
{
if(i==2)
continue;
printf("%d\n",i);
}
getch();
return 0;
}
output:
1
3
5
7
9
No comments:
Post a Comment