### Examples Using the continue Statement

The following example shows a continue statement in a for statement. The continue statement causes processing to skip over those elements of the array `rates` that have values less than or equal to `1`.

>     /**
>      ** This example shows a continue statement in a for statement.
>      **/

>     #include <stdio.h>
>     #define  SIZE  5

>     int main(void)
>     {
>        int i;
>        static float rates[SIZE] = { 1.45, 0.05, 1.88, 2.00, 0.75 };

>        printf("Rates over 1.00\n");
>        for (i = 0; i < SIZE; i++)
>        {
>           if (rates[i] <= 1.00)  /*  skip rates <= 1.00  */
>              continue;
>           printf("rate = %.2f\n", rates[i]);
>        }

>        return(0);
>     }

The program produces the following output:

>     Rates over 1.00
>     rate = 1.45
>     rate = 1.88
>     rate = 2.00

The following example shows a continue statement in a nested loop. When the inner loop encounters a number in the array `strings`, that iteration of the loop ends. Processing continues with the third expression of the inner loop. The inner loop ends when the '`\0`' escape sequence is encountered.

>     /**
>      ** This program counts the characters in strings that are part
>      ** of an array of pointers to characters.  The count excludes
>      ** the digits 0 through 9.
>      **/

>     #include <stdio.h>
>     #define  SIZE  3

>     int main(void)
>     {
>        static char *strings[SIZE] = { "ab", "c5d", "e5" };
>        int i;
>        int letter_count = 0;
>        char *pointer;
>        for (i = 0; i <SIZE; i++) /* for each string */
>                                  /* for each each character */
>            for (pointer="strings[i];" *pointer !="\0" ; ++pointer)
>            {                     /* if a number */
>                if (*pointer>= '0' && *pointer <= '9')
>                   continue;
>                letter_count++;
>            }
>        printf("letter count="%d\n&quot;," letter_count);
>     }

The program produces the following output:

>     letter count = 5

Compare this program with the third program in Examples Using the break Statement, which uses the break statement to perform a similar function.

continue Statement