×

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

CRC Program in C

CRC (Cyclic Redundancy Check) is an error-detection algorithm that is used to detect any errors that may have occurred during the transmission or storage of data. The basic idea behind...

4 minutes read.

Union in C

Union is a user-defined data type that is used to hold the different types of elements like structure. In union, all members share the same memory location. Syntax: union [union name] { ...

1 minute read.

Builtin functions of GCC compiler

Certain built-in functions are present in the GCC compiler. These features are as follows: Function_ built in_popcount (x) The number of 1s in data of the integer type can be counted using...

3 minutes read.

Merge and Merge sort with example in C

Assume we have two ordered Integer arrays, a[] and b[]. If we wish to combine them into another ordered array, such as c[], we can use the following straightforward technique. Compare...

3 minutes read.

Merge Sort in C

The merge sort follows the principle of the divide and conquers algorithm. Firstly it divides the input of an array into two halves and then calls itself for the two...

4 minutes read.

Use of Structure in C

We can usually use arrays in C programming to store elements of the same data type. We can use strings to store multiple elements of a character data type. Still,...

4 minutes read.

getch() function in C

getch() is a pre-define or built-in function present in the conio.h library. It returns the given character immediately without waiting for the enter key to be entered. By using getch()...

3 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.

Data Structures And Algorithms in C

C language is one of the most flexible and simple languages. So, it is always better to learn any concept in C language compared to other languages. Let us look...

13 minutes read.

Find median of 1D array using function in C

Introduction: Here, we discuss how we can find the median of a 1D array using a function in C. The median is the value in the middle of the sorted...

3 minutes read.

#error #pragma in C

#error, #pragma in C #error, also known as the error directive in the C language. It will not allow you to make any compilation fail and immediately issues a statement which...

4 minutes read.

How to use sine() function in C

What is Function? The function is a set of statements. It takes input and performs some computation to produce output. The process is a set of codes only achieved when it is...

3 minutes read.

Beep() function in C

Introduction: Beep is a function which is used in C programming language. The beep function uses to make a beep sound. In the C language, when we want to generate...

3 minutes read.

strtok() and strtok_r() functions in C with examples

strtok() and strtok_r() functions in C with examples C offer various strtok() and strtok r() methods for a string to be separated by a certain delimiter. Dividing a string is a...

2 minutes read.

Limitations of Synchronisation and Uses of Static Synchronisation in Multithreading

The multithreading component of java is the element around which the idea rotates as it permits simultaneous execution of at least two program pieces for the most significant usage of...

9 minutes read.

Sizeof in C

A pointer in C is defined as a variable that stores the information of the address of another variable. A pointer can be incremented or decremented, which means we can...

4 minutes read.

Find out Power without using POW function in C

Introduction: In this discussion, we will discuss how we find out power without using the POW function in C. In this article, you'll understand how to compute integer powers in...

3 minutes read.

Fibonacci Series in C Using For Loop

In this C article, we will let you know about the procedure of displaying the Fibonacci series of the first “n” positive integers. The syntax of for loop used in the...

4 minutes read.

Pointer to pointer in C

A pointer to another pointer is another type of multiple indirections and a chain of many pointers. Generally, a pointer consists of the address of the variable. Once a pointer to...

4 minutes read.

Deadlock Detection Program in C

What is Deadlock? A deadlock is a circumstance where a group in the process is halted because they are each holding onto resources while waiting for other methods to obtain them. Think...

5 minutes read.