Control Flow and Loops in C

  • Post author:
  • Post category:c
  • Post comments:0 Comments

Control Flow and Loops in C

In this lesson, you will learn about the different types of control flow statements in C programming. Control flow statements are used to control the flow of execution in a program. These include the if/else statement, for loop, and while loop. You will also learn about the break and continue statements.

Example

#include <stdio.h> 

int main() 
{ 
    int i; 
  
    for(i = 1; i <= 10; i++) 
    { 
        if(i % 2 == 0) 
            printf("%d is even\n", i); 
        else 
            printf("%d is odd\n", i); 
    } 
  
    return 0; 
}

Output

1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even

Leave a Reply