×

Continue in C

C language:

C language is a procedure oriented programming language. We can say that it is a platform dependent language. C language is introduced by Dennis Ritchie in the year 1970.

We can create many applications using C programming language. There are many applications that are based on C language. We can also say that C language is a low level programming language.

There are any data types such as int, char, float, double etc and many other tokens , keywords in C programming language. One of such key word is continue. Now let us learn about the key word “ continue “ in detail.

Continue:

In C programming, the continue statement functions similarly to the break statement. It skips any code in between and compels the next iteration of the loop rather than imposing termination. The conditional test and increment sections of the for loop are executed as a result of the continue statement.

The continue statement skips the remainder of the do, for, or while statement body and transfers control to the subsequent iteration of the nearest enclosing do, for, or The do, for, or while statement's subsequent iteration is chosen as follows:

  • The following iteration of a do or while statement begins with a reevaluation of the statement's phrase.
  • The conditional statement is then reevaluated by the code. It either ends or iterates the statement body depending on the outcome.
  • See The for statement for additional details on the for statement and its nonterminals.

Syntax of continue key word :

There is a particular syntax to define continue statement or keyword in C programming language.

1.Syntax of continue in while loop

while(condition)
{
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
continue;
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
}

2. Syntax of continue in do while loop

do
{
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
continue;
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ } while (condition);

3. Syntax of continue in for loop

for(_ _ _ ; _ _ _ ;_ _ _)
{
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
continue;
//_ _ _ _ _ _ _ _ 
 //_ _ _ _ _ _ _ _ 
//_ _ _ _ _ _ _ _ 
}

Now let us see few examples based on continue key word by using the following codes as shown below :

Example 1:

# include < stdio.h >
# include < conio.h >
void main ( void )
{
int a=0;
while ( i ! = 10 )
{
printf ( “ %d “ , a );
continue;
a++;
} // while loop
} // main 

Output 1 :

infinite loop

Example 2:

# include < stdio.h >
# include < conio.h >
void main ( void )
{
int a=1;
for(a=0;a<=15;a++)
{
if( a == 5 )
{
continue;
} // if
printf ( “ %d \n “ , a);
} // for loop
} // main

Output 2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Example 3:

# include < stdio.h >
# include < conio.h >
void main ( void )
{
int a=1 , b=1;
for(a=1;a<=3;a++)
{
for(b=1;b<=3;b++)
{
if ( a == 2 && b == 2 )
{
continue;
 } // 
if
printf ( “ %d %d \n “ , a , b );
} // inner loop
} // outer loop
} // main

Output 3:

1    1
1    2
1    3
2    1
2    3
3    1
3    2
3    3

Here in all these examples we can see that the loop continues after the condition or the statement.


Related Topics

Difference between while and do-while loop in C

Introduction Both 'While' and 'Do-While' loops in C mostly have a similar concept, and the code of both loops runs for mainly similar purposes. Both loops process the program/code in the...

3 minutes read.

getc() function in C

Getc is one of the file handling technique in C. The Getc() is a C library function gets the next character or new characters  from the specific stream and supports...

4 minutes read.

Armstrong program in C using function

In this article we will learn how to find Armstrong of a number using function in C. An Armstrong number is a three-digit number that is the sum of its separate...

1 minute read.

How to return a Pointer from a Function in C?

In the C programming language, pointers are variables that hold the address memory location of another variable. We could also input pointers to a function and return pointers from a...

3 minutes read.

Dangling pointers in C

Dangling pointers in C: A pointer is a variable that stores the memory address of other variables. The pointers may also store the address of other’s memory items. They are...

4 minutes read.

C Language Environment Setup

To compile C program, we must have GCC compiler installed on our machine. In this C tutorial, all the examples are compiled and tested using GCC compiler. Although we can...

3 minutes read.

Factorial Program in C using For Loop

Before move on the factorial program. We have to know about the for loop in C programming language. The syntax of the For Loop is: for (initialization statement; test expression; an increment...

3 minutes read.

OpenGL in C

OpenGL stands for Open Graphics Library. It is a low-level, widely supported modeling and rendering software package that is widely available across all the platforms. It is an API used...

4 minutes read.

Comma Operator in C

What is a comma operator? The comma operator in the C programming language has the least priority. The comma operator is essentially a binary operator that operates on the first operand...

4 minutes read.

What is algorithm in C?

What is an algorithm? In computer programming languages, an algorithm is set of statement that solves a particular problem. In C, first step of every algorithm is Start and last step of...

3 minutes read.

Keywords in C

A keyword is a word that has a predetermined meaning. The C compiler knows the purposes of the keywords. The objectives of these keywords cannot be modified. Keywords are the...

9 minutes read.

C Program for Mean and Median of an Unsorted Array

In this tutorial, we will look at how to determine the mean and median of a given unsorted array. To determine the Mean: To get the average, mean is determined. The formula...

2 minutes read.

C printf and Scanf

Input-Output functions in C Programming In C Language, the printf() and scanf() are inbuilt library functions that used for input and output. It is defined in the header file“<stdio.h>”. printf() Function: In C...

2 minutes read.

Floyd’s triangle in C

Floyd’s triangle in C Floyd’s triangle is named after a person Robert Floyd. It is a right-angled triangle that is of natural numbers starting from 1 and consecutively selects the upcoming...

4 minutes read.

Reverse a Stack using Recursion in C

In this tutorial we will learn how recursion will be used in this case to reverse a stack. For loops, while loops, do-while loops, and similar constructions are not permitted....

5 minutes read.

Exponential() in C

Introduction: In C language, there are available many types of functions. The exponential() function is one of them. It is a mathematical function. This article describes using the pow() property to...

3 minutes read.

Multi-dimensional Arrays in C

Multi-dimensional Arrays in C The C programming allows the concept of multi-dimensional arrays. The data within the multidimensional arrays are stored in the tabular form, that is, in a row significant...

3 minutes read.

FIFO Example in the C Language

FIFO is an acronym that means "First In, First Out." It is a data structure handling method in which the first element is handled first, and the last element is...

3 minutes read.

Conditional Operator in C

In C programming language, the conditional operator (also known as the ternary operator) is a shorthand way of writing an if-else statement. The syntax of conditional operator in C is...

3 minutes read.

Do-While Loop in C

Both 'While' and 'Do-While' loops in C mostly have a similar concept, and the code of both loops runs for mainly similar purposes in the same manner. But, there is...

3 minutes read.