Home Show/Hide Menu
C Tutorials
➜ C Language
  - Features of C
  - First C Program
  - Compilation in C
  - C Character Set
  - Tokens
  - Keywords
  - Identifiers
  - Constants
  - Operators
  - Data Types
  - Variables
  - Type Casting
  - Comments
  - Input/Output
  - Escape Sequence
  - Programming Errors
➜ Control Statements
  - if Statement
  - if-else Statement
  - Nested if-else
  - else-if
  - switch Statement
  - Loop
  - while loop
  - do while loop
  - for loop
  - break
  - continue & goto
  - Nested Loop
  - Infinite Loop
➜ Functions
  - What is function
  - Call by Value & Reference
  - Recursive function
  - Storage Classes
➜ Array
  - 1-D Array
  - 2-D Array
  - Return an Array
  - Array to Function
➜ C Pointers
  - Pointers
  - Pointer to Pointer
  - Pointer Arithmetic
  - Dangling Pointers
  - sizeof() operator
  - const Pointer
  - void pointer
  - Dereference Pointer
  - Null Pointer
  - Function Pointer
  - Function pointer as argument
➜ Memory Management
  - Memory Layout of C
  - Dynamic memory
  - calloc()
  - malloc()
  - realloc()
  - free()
➜ Strings
  - gets() & puts()
  - String Functions
  - strlen()
  - strcpy()
  - strcat()
  - strcmp()
  - strrev()
  - strlwr()
  - strupr()
  - strstr()
➜ C Math
  - Math Functions
➜ Enum, Structure & Union
  - Enum
  - Structure
  - typedef
  - Array of Structures
  - Nested Structure
  - Structure Padding
  - Union
➜ File Handling
  - fprintf() fscanf()
  - fputc() fgetc()
  - fputs() fgets()
  - fseek()
  - EOF and feof()
  - fsetpos()
  - tmpfile()
  - rewind()
  - ftell()
  - lseek()
➜ Preprocessor
  - Preprocessor
  - Macros
  - #include
  - #define
  - #undef
  - #ifdef
  - #ifndef
  - #if
  - #else
  - #error
  - #pragma
➜ Command Line
  - Arguments

Continue Statement in C Language

In C programming language, the continue statement is used to continue the execution of the loop. It is sometimes desirable to skip some statements inside the loop. The continue statement is almost always used with the if...else statement within the block of the while, do while and for loop.

Continue statement with loop
// Program to calculate the sum of maximum 10 numbers
// If the user inputs a negative number, it's not calculated to the result
#include<stdio.h>
#include<conio.h>
void main()
{
   int i;
   double num, sum = 0.0;

   for (i = 1; i <= 10; ++i) {
      printf("Enter a no%d: ", i);
      scanf("%lf", &num);

      if (num < 0.0) {
         continue;
      }

     sum = sum + num;
   }

   printf("Sum = %.2lf", sum);
   getch();
}

Output :

Enter no1: 1.2
Enter no2: 2.1
Enter no3: 4.5
Enter no4: 5.4
Enter no5: -15.9
Enter no6: -6.7
Enter no7: 24.5
Enter no8: -9.2
Enter no9: -500
Enter no10: 11.1
Sum = 48.80
When the user inputs a positive number, the sum is evaluted using sum = sum + num; statement.
When the user inputs a negative number, then the continue statement is executed and it skips the negative number calculation.

Goto Statement

In C programming, goto statement is used to transfer the unconditional program control to some other part of the program using a labeled statement.

Syntax:

goto label;
.............
.............
.............
label:
  statement;
In this syntax, label is used as an identifier.
When, the control of program reaches to goto statement, the control of the program will jump to the label: and executes the code below of the label.


// Program to find the length of a given string
#include<stdio.h>
#include<conio.h>
void main()
{
   int a = 10;

   /* do loop execution */
   loop:  //loop is a label
   do {
   
      if( a > 13 && a<16) {
         /* skip the iteration */
         a = a + 1;
         goto loop;  //This jumps to label "loop:"
      }
		
      printf("value of a: %d\n", a);
      a++;

   }while( a < 20 );
   getch();
}

Output :

value of a: 10
value of a: 11
value of a: 12
value of a: 17
value of a: 18
value of a: 19
ADVERTISEMENT