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

Control Statements in C Language

In general, control statements in C are used to execute/transfer the control. It helps to control the order in which the statements to be execute. In a procedural language, the program's flow is usually from top to bottom (means Sequential flow). But in most C programs the programmer may want to execute a particular set of instructions when it fulfills a specific condition or wants to run a set of instructions for a specified number of times. This can be referred as sequential control flow statement. The various types of control statements in C language are as under:-

  • Sequential
  • Conditional
  • Iteration

Sequential control

In sequential control, the C program statements are executed sequentially i.e., one after the another from beginning to end.

 Statement 1 
 Statement 2 
 Statement 3 

#include<stdio.h>
void main()
{
	int x , y, sum;
	printf("Enter the two numbers");
	scanf("%d%d",&x,&y);
	sum=x+y;
	printf("Sum=%d",sum);
} 

Conditional Control (Decision Control)

In conditional control, the execution of statements depends on the condition. If the condition is true, then a set of statements is executed otherwise other set of statements is followed. This control is also called Decision Control because it helps in making decision about which set of statements is to be executed. Decision control structure in C can be implemented by using -

  1. If statement
  2. If-else statement
  3. Nested if else statement
  4. else-if ladder
  5. case control structure
  6. conditional operator

Iteration Control ( Loops )

Iterations or loops are used when programmer want to execute a statement or block of statements repetedly. The repetition of loops is controlled with the help of a condition. The statements in the loop keep on executing repetedly until the condition becomes false. There are the following three types of loops:-

  1. While loop
  2. Do-while loop
  3. For loop

ADVERTISEMENT