SlideShare a Scribd company logo
Control Statements in C
Prof. Navya Francis
Asst. Professor
Kristu Jayanti College
• The control statements in programming languages decide the
direction of the flow of program execution.
• They are also known as decision control structures.
Introduction
Need of Conditional Statements
In everyday situations, we often find ourselves making decisions that influence our
subsequent actions.
Likewise, within the domain of programming, there are scenarios that necessitate decision-
making, with the subsequent course of action dictated by these choices, shaping the
execution of the succeeding code block.
Types of Conditional Statements in C/C++
oif Statement
oif-else Statement
oNested if Statement
oif-else-if Ladder
oswitch Statement
oConditional Operator
oJump Statements:
o break
o continue
o goto
o return
If Statement
• The "if" statement in C serves as a decision-making construct,
allowing the execution of a code block contingent on the evaluated
expression's value. This fundamental concept in C programming
enables the incorporation of conditional code within our program.
Syntax:
if(condition)
{
// Statements to execute if condition is true
}
Flowchart
Example 1: C Program to check whether the
number is even or odd.
# include ,stdio.h>
void main
{
int n = 10;
if(n%2==0)
{
printf(“%d is Even number”,n);
}
}
Output
10 is Even number
if else statement
• The if-else statement is employed when there is a need to execute certain
code if a condition is true and an alternative code if the condition is false.
• Following an if statement, an optional else statement can be included,
activating when the boolean expression evaluates to false.
Syntax:
if(condition)
{
/* statement(s) will execute if the
boolean expression is true */
}
else
{
/* statement(s) will execute if the
boolean expression is false */
}
Flowchart:
Nested if statement
A nested if statement is an if statement placed
inside another if statement. Nested if statements
are often used when you must test a combination
of conditions before deciding on the proper
action. ie.)You can use one if or else if statement
inside another if or else if statement(s).
Syntax:
if ( test condition 1)
{
//If the test condition 1 is TRUE then these it will check for test condition 2
if ( test condition 2)
{
//If the test condition 2 is TRUE then these statements will be executed
Test condition 2 True statements;
}
else
{
//If the test condition 2 is FALSE then these statements will be executed
Test condition 2 False statements;
}
else
{
//If the test condition 1 is FALSE then these statements will be executed
Test condition 1 False statements;
}
else if ladder/if else ladder
else if ladder/if else ladder if-else ladder is an extension of if…else statement.
By using one if-else construct, it is possible to choose between two choices.
There may be a situation wherein it is required to select one among more
than two choices. This can be accomplished by another if-else in the else
part of the construct. This type of if construct is called as else if ladder
statement.
Syntax:
if(condition 1)
statement 1;
else if(condition 2)
statement 2;
"
"
"
else if(condition n)
statement n;
else default statement;
Thank You

More Related Content

DOCX
Chapter 4(1)
PPTX
Conditional control statements explains the programming constructs
PPT
_Java__Expressions__and__FlowControl.ppt
PPT
_Java__Expressions__and__FlowControl.ppt
PPTX
Unit-2 control Structures.pptx.pptx20201
PPTX
Control Statement programming
PPTX
Computer programming 2 Lesson 9
PPTX
Computer programming 2 - Lesson 7
Chapter 4(1)
Conditional control statements explains the programming constructs
_Java__Expressions__and__FlowControl.ppt
_Java__Expressions__and__FlowControl.ppt
Unit-2 control Structures.pptx.pptx20201
Control Statement programming
Computer programming 2 Lesson 9
Computer programming 2 - Lesson 7

Similar to C Programming: Control Statements in C Pgm (20)

PDF
Unit 2=Decision Control & Looping Statements.pdf
PPTX
Decision control structures
PPT
control-statements detailed presentation
PPTX
Control statements in java
PPTX
Cse lecture-6-c control statement
PDF
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
PPT
Decision making and branching
PPTX
Flow of control C ++ By TANUJ
PPTX
CSE-1203-Lecture-05-Branching. for c programmepptx
PPTX
DECISION MAKING AND BRANCHING - C Programming
PPTX
control-statements in C Language MH.pptx
PPTX
Decision Making Statement in C ppt
PDF
itft-Decision making and branching in java
PPTX
Constructs (Programming Methodology)
PPT
cprogrammingprogramcontrolsHJKHJHJHJ.ppt
PDF
Learn C# Programming - Decision Making & Loops
DOCX
PPS 3.3CONDITIONAL BRANCHING AND LOOPS WRITING AND EVALUATION OF CONDITIONAL...
PPT
2. Control structures with for while and do while.ppt
PPTX
Flow of control by deepak lakhlan
Unit 2=Decision Control & Looping Statements.pdf
Decision control structures
control-statements detailed presentation
Control statements in java
Cse lecture-6-c control statement
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Decision making and branching
Flow of control C ++ By TANUJ
CSE-1203-Lecture-05-Branching. for c programmepptx
DECISION MAKING AND BRANCHING - C Programming
control-statements in C Language MH.pptx
Decision Making Statement in C ppt
itft-Decision making and branching in java
Constructs (Programming Methodology)
cprogrammingprogramcontrolsHJKHJHJHJ.ppt
Learn C# Programming - Decision Making & Loops
PPS 3.3CONDITIONAL BRANCHING AND LOOPS WRITING AND EVALUATION OF CONDITIONAL...
2. Control structures with for while and do while.ppt
Flow of control by deepak lakhlan
Ad

More from Navya Francis (11)

PPTX
Data Warehosuing & Data Mining: Apriori Algorithm
PPTX
Data Warehosuing & Data Mining: FP Growth
PPTX
C Programming: Looping Statements in C Pgm
PPTX
Data Warehousing & Data Mining: Introduction
PPTX
C Programming: Basic Structure of C Program
PPTX
Data Structures: Introduction to Data Structures
PPTX
JAVA Programming : Topic JAVA Programming Swing
PPTX
JAVA Programming: Topic -AWT(Abstract Window Tool )
PPTX
Data Structures: Classification of Data Structures
PPTX
Software Engineering Topic: Risk Management
PPTX
Software Engineering: Topic: Waterfall Model
Data Warehosuing & Data Mining: Apriori Algorithm
Data Warehosuing & Data Mining: FP Growth
C Programming: Looping Statements in C Pgm
Data Warehousing & Data Mining: Introduction
C Programming: Basic Structure of C Program
Data Structures: Introduction to Data Structures
JAVA Programming : Topic JAVA Programming Swing
JAVA Programming: Topic -AWT(Abstract Window Tool )
Data Structures: Classification of Data Structures
Software Engineering Topic: Risk Management
Software Engineering: Topic: Waterfall Model
Ad

Recently uploaded (20)

PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Computing-Curriculum for Schools in Ghana
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Presentation on HIE in infants and its manifestations
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
2.FourierTransform-ShortQuestionswithAnswers.pdf
O7-L3 Supply Chain Operations - ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
Computing-Curriculum for Schools in Ghana
Module 4: Burden of Disease Tutorial Slides S2 2025
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .
Classroom Observation Tools for Teachers
master seminar digital applications in india
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Presentation on HIE in infants and its manifestations
Chinmaya Tiranga quiz Grand Finale.pdf
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
Supply Chain Operations Speaking Notes -ICLT Program
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE

C Programming: Control Statements in C Pgm

  • 1. Control Statements in C Prof. Navya Francis Asst. Professor Kristu Jayanti College
  • 2. • The control statements in programming languages decide the direction of the flow of program execution. • They are also known as decision control structures. Introduction
  • 3. Need of Conditional Statements In everyday situations, we often find ourselves making decisions that influence our subsequent actions. Likewise, within the domain of programming, there are scenarios that necessitate decision- making, with the subsequent course of action dictated by these choices, shaping the execution of the succeeding code block.
  • 4. Types of Conditional Statements in C/C++ oif Statement oif-else Statement oNested if Statement oif-else-if Ladder oswitch Statement oConditional Operator oJump Statements: o break o continue o goto o return
  • 5. If Statement • The "if" statement in C serves as a decision-making construct, allowing the execution of a code block contingent on the evaluated expression's value. This fundamental concept in C programming enables the incorporation of conditional code within our program.
  • 6. Syntax: if(condition) { // Statements to execute if condition is true } Flowchart
  • 7. Example 1: C Program to check whether the number is even or odd. # include ,stdio.h> void main { int n = 10; if(n%2==0) { printf(“%d is Even number”,n); } } Output 10 is Even number
  • 8. if else statement • The if-else statement is employed when there is a need to execute certain code if a condition is true and an alternative code if the condition is false. • Following an if statement, an optional else statement can be included, activating when the boolean expression evaluates to false.
  • 9. Syntax: if(condition) { /* statement(s) will execute if the boolean expression is true */ } else { /* statement(s) will execute if the boolean expression is false */ } Flowchart:
  • 10. Nested if statement A nested if statement is an if statement placed inside another if statement. Nested if statements are often used when you must test a combination of conditions before deciding on the proper action. ie.)You can use one if or else if statement inside another if or else if statement(s).
  • 11. Syntax: if ( test condition 1) { //If the test condition 1 is TRUE then these it will check for test condition 2 if ( test condition 2) { //If the test condition 2 is TRUE then these statements will be executed Test condition 2 True statements; } else { //If the test condition 2 is FALSE then these statements will be executed Test condition 2 False statements; } else { //If the test condition 1 is FALSE then these statements will be executed Test condition 1 False statements; }
  • 12. else if ladder/if else ladder else if ladder/if else ladder if-else ladder is an extension of if…else statement. By using one if-else construct, it is possible to choose between two choices. There may be a situation wherein it is required to select one among more than two choices. This can be accomplished by another if-else in the else part of the construct. This type of if construct is called as else if ladder statement.
  • 13. Syntax: if(condition 1) statement 1; else if(condition 2) statement 2; " " " else if(condition n) statement n; else default statement;