C - Statements
Learn C - C tutorial - C if statement - C examples - C programs
Control Statements in C - Definition and Usage
- In C- Programming Control statements are used for defining and enabling the flow of program control;
i.e., the order in which the instructions in a program must be executed. - They make it possible to make decisions, to perform tasks repeatedly or to jump from one section of code to another.
- There are three types of control statements in C :
- Decision making statements
- Selection statements
- Looping statements
Types of Decision Making Statements
- In C- Programming decision making statements are used for defining the group of statements which will be executed when condition is true.
- If condition is false, then else part statements will be executed.
- There are three types of decision making control statements in C language.
- if statements
- if else statements
- nested if statements
C If Statement - Definition and Usage
- In C- Programming the if statement is a conditional branching statement that is if the condition is satisfied the respective block of code is executed.
C If Else Statement- Definition and Usage
- In these type of statements, group of statements are executed when condition is true.
- If condition is false, then else part statements will be executed.
C Else If Statement - Definition and Usage
- In C- Programming the Else If statement works like, the if condition works if the condition is true, if condition is false the else condition works, certainly further on if the else condition is false once again the else condition will be executed.
C Switch Statement - Definition and Usage
- In C- Programming the switch statemen t is used for defining multiple possibilities for the if statement.
- In general, the switch statement is executing only specific case statements based on the switch expression.
Loops in C - Definition and Usage
- In C- Programming the control statement is used for performing looping operations until the given condition is true.
- Control comes out of the loop statements once condition becomes false.
- C loops execute a block of commands for the specific number of times, until a condition is met or satisfied.
- In C-program, there are three different types of control statement as follows:
C While Loop Statement - Definition and Usage
- In C- Programming the while statement is considered as a looping statement.
- In C , the while Loop is executed, only when condition is true.
C Do While Loop Statement - Definition and Usage
- In C- Programming the do while statement is a looping statement.
- In C – Programming the do while Loop is executed at least one time then after executing the while loop for first time, then condition is checked.
C For Loop Statement - Definition and Usage
- In C- Programming the for loop is used to execute a set of statements repeatedly until a particular condition is satisfied. We can say it an open ended loop. General format is,