In C programming using the continue keyword in For Loop control flow statement causes the loop to jump to the next iteration of the loop immediately.
#include<stdio.h>
#include<conio.h>
void main()
{
for(int a = 1; a <= 10; a++) //loop looping from 1 to 10.
{
if(a == 5) //if 'a' value equal to 5 then
{
continue; //continue it mean skip 5.
}
printf("%d\n", a);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
for(int a = 1; a <= 10; a++) //loop looping from 1 to 10.
{
for(int b = 1; b <= a; b++) //loop looping from 1 to 'a' value.
{
printf("*");
}
printf("\n"); //used for New Line.
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<stdlib.h> //including Library for Random.
void main()
{
printf("Ten random numbers in [1, 10]\n");
for(int i = 1; i <= 10; i++) //loop looping from 1 to 10.
{ //random number from 1 to 10 and assigning to 'n'.
int n = rand() % 10 + 1;
printf("%d\n", n); //and printing.
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<stdlib.h> //including library for Random.
void main()
{
printf("Ten random numbers in [1, 10]\n");
for(int i = 1; i <= 10; i++) //loop looping from 1 to 10.
{ //random Number from 1 to 10 and assigning to 'n'.
int num = random(10); //Random from 0 to 10 and assigning
printf("%d\n", num); //to 'num' and printing.
}
getch();
}