Definition
syntax
flowchart
example
Definition:
It is sometimes desirable to skip some statements inside the loop. In such cases, continue statements are used.
Syntax:
continue;
Just like break, continue is also used with conditional if statement.
flow chart:
Example of continue statement
Write a C program to find the product of 4 integers entered by a user. If user enters 0 skip it.
//Program to demonstrate the working of continue statement in C programming
# include <stdio.h>
void main(){
int i,n,product;
for(i=1,product=1;i<=4;++i){
printf("Enter n%d:",i);
scanf("%d",&n);
if(n==0)
continue; / *In this program, when num equals to zero, it skips the statement product*=num and continue the loop. */
product*=n;
}
printf("product=%d",product);
return 0;
}
Output
Enter n1:3
Enter n2:0
Enter n3:-5
Enter n4:2
product=-30
Example program on continue statement
unconditional statements
Return statement
No comments:
Post a Comment