How to use continue statement in C

1 Answer

0 votes
#include <stdio.h>

int main(void)
{
    int i = 0;
    
    printf("while\n");
    while (i++ < 10) 
    {
        if (i % 2 == 0)
            continue; 
            
        printf("%d\n", i);
    }
        
    i = 0;
    printf("\ndo - while\n");
    do
    {
        if (i % 2 == 0)
            continue; 
            
        printf("%d\n", i);
        
    } while (i++ < 10) ;
    
    printf("\nfor\n");
    for (i = 0; i < 10; i++)
    {
        if (i % 2 == 0)
            continue; 
            
        printf("%d\n", i);
    }
    
    return 0;
}

/*
run:
 
while
1
3
5
7
9

do - while
1
3
5
7
9

for
1
3
5
7
9

*/

 



answered Aug 30, 2016 by avibootz

Related questions

2 answers 288 views
1 answer 150 views
1 answer 233 views
1 answer 180 views
1 answer 213 views
213 views asked Jan 15, 2016 by avibootz
1 answer 297 views
...