C – Case control statements

Prev     Next

The statements which are used to execute only specific block of statements in a series of blocks are called case control statements.

There are 4 types of case control statements in C language. They are,

  1. switch
  2. break
  3. continue
  4. goto

1. switch case statement in C:

  • Switch case statements are used to execute only specific case statements based on the switch expression.
  • Below is the syntax for switch case statement.

switch (expression)
     case label1:   statements;
     case label2:   statements;
     case label3:   statements;
     default:      statements;

Example program for switch..case statement in C:


Value is 3

2. break statement in C:

  • Break statement is used to terminate the while loops, switch case loops and for loops from the subsequent execution.
  • Syntax: break;

Example program for break statement in C:


0 1 2 3 4
Coming out of for loop when i = 5

3. Continue statement in C:

  • Continue statement is used to continue the next iteration of for loop, while loop and do-while loops.  So, the remaining statements are skipped within the loop for that particular iteration.
  • Syntax : continue;

Example program for continue statement in C:


0 1 2 3 4
Skipping 5 from display using continue statement
Skipping 6 from display using continue statement
7 8 9

4. goto statement in C:

  • goto statements is used to transfer the normal flow of a program to the specified label in the program.
  • Below is the syntax for goto statement in C.

         go to label;

Example program for goto statement in C:


0 1 2 3 4
We are using goto statement when i = 5
Now, we are inside label name “hai”

Prev     Next

Share this website !!!
Facebook Twitter Linkedin

1. Online Compilers - Compile & Run your C/C++ programs:

✅ Online Compilers

2. Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com

We Support JALLIKATTU !!!
By Fresh2Refresh.com
Show Your Support as well. Thanks!