Continue Statement : It is used when we want to continue running the loop but stop processing the remaining code in it's body for this particular iteration.
Code goes like this :
/* WAP that asks for a number a from user and then display only even numbers from 2 to n using continue statement */
#include<stdio.h>
int main()
{
int i,num;
printf("\n Enter a number:");
scanf("%d",&num);
printf("\n The even numbers from 2 to %d are:\n",num);
for(i=1;i<=num;i++)
{
if(i%2!=0)
continue;
printf("\t%d",i);
}
return 0;
}
Output :
Home / C Programs /
continue statement in C /
Odd and even in C /
Printing even numbers in C
/ Printing even numbers till nth number using continue statement in C
- Blogger Comment
- Facebook Comment
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment