Control statements are heart of any programming language. In your programming life you will find 60-70% of your program consist control statements. To master the art of programming, you must have a good control over your program. You must have a solid grip over control statements.
Every program by default execute sequentially. Each and every statement is executed one after other. However, there happen situations when you need to execute statement/s based on conditions. Such as display confidential files only if user has authentic credentials.
You may come across situation when you need to execute set of statements repeatedly. Such as send offer email to all clients.
Control statements in programming handles such situations. Control statement is divided in three categories.
Decision statement is condition based statement. It define single or set of conditions that must be satisfied before statement/s can execute. For example, allow amount withdrawal from ATM, only if pin validation succeeds. These situations are handled using decision statements.
Decision statements are also known as conditional or branching statement. In decision statement we will learn about -
Practice exercises -
Looping statement defines a set of repetitive statements . These statements are repeated, with same or different parameters for a number of times.
In programming, there exists situations when you need to repeat single or a group of statements till some condition is met. Such as - read all files of a directory.
Looping statements are also known as iterative or repetitive statement.
There are three types of looping statement in C.
Unlike conditional and looping statement, jump statement provides unconditional way to transfer control from one part of program to other.
C supports three jump statements.