You are on page 1of 7

C TRAINING

BY APTUTS.COM
EMAIL: LEARN@APTUTS.COM

ABOUT ME
Bachelor's Degree in Computer Science Engineering
Software Engineer in IT Industry & Teaching Experience
7 Years of IT experience in various technologies
Expertise in C, C++, Application Development, Manual Testing, Web Automation Testing, Mobile
Automation Testing, Website Designing, PHP and VBScript
Founder of LearnCOnline.com, LearnCPPOnline.com and Aptuts.com
Contact Info: prashant@aptuts.com

WHAT IS CONTROL STATEMENT?


As the name says, control statements are used to alter the normal sequential flow of the
program execution
Normal Flow

Altered Flow

Step 1

Step 1

Step 2

Step 2

Step 3

Step 3

Using Control instructions


we can move from Step 1
to Step 3 skipping Step 2

CONTROL STATEMENTS IN C
Control statements alter the flow of execution of the programs. Control statements can be broadly
divided into three categories:
1. Decision-making or Conditional Statements

2.

Loop Statements

3.

if statement
if-else statement
switch statement
for statement
while statement
do-while statement

Breaking Control Statements

break statement
continue statement
goto statement

CONTROL STATEMENTS IN C
if conditional statement
if statement is used to express the conditional expressions.
If the given condition is true then it will execute the
statements otherwise it will skip it and execute the
optional statements

int a = 10;
if (a == 10){
printf(You are in if block\n);
printf(The value of a is %d\n, a);
}
printf(You are out of if block);

Syntax:
if (condition is true){
/*block of statements to be executed*/
}

Output:
You are in if block
The value of a is 10
You are out of if block

DEMO OF IF STATEMENT
Let us write and run a simple C program to demonstrate how if statement works.
Scenario:

Accepts a value from user


If the value is greater than 10, display the message Value greater than 10 else display Value
less than 10

Note:
We will be using if decision control statement to write the above program

THANK YOU

Web: www.aptuts.com
Email: learn@aptuts.com
Social: www.facebook.com/aptuts

You might also like