SlideShare a Scribd company logo
CONTROL STATEMENTS/DECISION MAKING
Decision making structures require that the programmer specifies
one or more conditions to be evaluated or tested by the program,
along with a statement or statements to be executed if the condition
is determined to be true, and optionally, other statements to be
executed if the condition is determined to be false.
There are the following variants of if statement in C language.
•If statement
•If-else statement
•If else-if ladder
•Nested if
IF STATEMENT
The if statement is used to check some given condition and perform
some operations depending upon the correctness of that condition.
It is mostly used in the scenario where we need to perform the
different operations for the different conditions.
The syntax
if(expression){
//code to be executed
}
FLOW DIAGRAM
IF-ELSE STATEMENT
•The if-else statement is used to perform two operations for a single
condition.
•The if-else statement is an extension to the if statement using which,
we can perform two different operations, i.e., one is for the
correctness of that condition, and the other is for the incorrectness of
the condition.
The syntax of the if-else statement is given below.
if(expression){
//code to be executed if condition is true
}else{
//code to be executed if condition is false
}
IF ELSE-IF LADDER STATEMENT
The if-else-if ladder statement is an extension to the if-else
statement.
 It is used in the scenario where there are multiple cases to be
performed for different conditions.
In if-else-if ladder statement, if a condition is true then the
statements defined in the if block will be executed, otherwise if some
other condition is true then the statements defined in the else-if
block will be executed, at the last if none of the condition is true then
the statements defined in the else block will be executed.
SWITCH STATEMENT
•The switch statement in C is an alternate to if-else-if ladder
statement which allows us to execute multiple operations for the
different possibles values of a single variable called switch variable.
•Here, We can define various statements in the multiple cases for the
different values of a single variable.
C LOOPS
The looping can be defined as repeating the same process multiple
times until a specific condition satisfies.
Types of C Loops
There are three types of loops in C language that is given below:
•do while
•while
•for
WHILE LOOP IN C
A while loop in C programming repeatedly executes a target
statement as long as a given condition is true.
Syntax
The syntax of a while loop in C programming language is −
while(condition) {
statement(s);
}
FOR LOOP IN C
A for loop is a repetition control structure that allows you to
efficiently write a loop that needs to execute a specific number of
times.
Syntax
The syntax of a for loop in C programming language is −
for ( init; condition; increment ) {
statement(s);
}
DO...WHILE LOOP IN C
•Unlike for and while loops, which test the loop condition at the top of
the loop, the do...while loop in C programming checks its condition
at the bottom of the loop.
•A do...while loop is similar to a while loop, except the fact that it is
guaranteed to execute at least one time.
The syntax of a do...while loop in C programming language is −
do {
statement(s);
} while( condition );
Notice that the conditional expression appears at the end of the loop,
so the statement(s) in the loop executes once before the condition is
tested.
C COMMENTS
•Comments can be used to explain code, and to make it more
readable. It can also be used to prevent execution when testing
alternative code.
•Comments can be singled-lined or multi-lined.
SINGLE-LINE COMMENTS
Single-line comments start with two forward slashes (//).
Any text between // and the end of the line is ignored by the compiler (will
not be executed).
This example uses a single-line comment before a line of code:
Example
// This is a comment
printf("Hello World!");
C MULTI-LINE COMMENTS
Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored by the compiler:
Example
/* The code below will print the words Hello World!
to the screen, and it is amazing */
printf("Hello World!");

More Related Content

Similar to DECISION MAKING.pptx

While loop
While loopWhile loop
While loop
Feras_83
 
Unit II.pptx
Unit II.pptxUnit II.pptx
Unit II.pptx
zeenatparveen24
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
Rj Baculo
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
Emroz Sardar
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
FarshidKhan
 
Loops
LoopsLoops
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
Shahzu2
 
Loop structures
Loop structuresLoop structures
Loop structures
tazeem sana
 
Control statements
Control statementsControl statements
Control statements
CutyChhaya
 
LOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptxLOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptx
AFANJIPHILL
 
The Loops
The LoopsThe Loops
The Loops
Krishma Parekh
 
Control structure
Control structureControl structure
Control structure
Samsil Arefin
 
Java -lec-4
Java -lec-4Java -lec-4
Java -lec-4
Zubair Khalid
 
R loops
R   loopsR   loops
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
AbhiYadav655132
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
University of Potsdam
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
Sriman Sawarthia
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
Anil Dutt
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
muhammadFaheem656405
 
6.pptx
6.pptx6.pptx

Similar to DECISION MAKING.pptx (20)

While loop
While loopWhile loop
While loop
 
Unit II.pptx
Unit II.pptxUnit II.pptx
Unit II.pptx
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
Loops
LoopsLoops
Loops
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Control statements
Control statementsControl statements
Control statements
 
LOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptxLOOPING IN C- PROGRAMMING.pptx
LOOPING IN C- PROGRAMMING.pptx
 
The Loops
The LoopsThe Loops
The Loops
 
Control structure
Control structureControl structure
Control structure
 
Java -lec-4
Java -lec-4Java -lec-4
Java -lec-4
 
R loops
R   loopsR   loops
R loops
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
 
6.pptx
6.pptx6.pptx
6.pptx
 

Recently uploaded

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 

Recently uploaded (20)

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 

DECISION MAKING.pptx

  • 2. Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
  • 3. There are the following variants of if statement in C language. •If statement •If-else statement •If else-if ladder •Nested if
  • 4. IF STATEMENT The if statement is used to check some given condition and perform some operations depending upon the correctness of that condition. It is mostly used in the scenario where we need to perform the different operations for the different conditions. The syntax if(expression){ //code to be executed }
  • 6.
  • 7. IF-ELSE STATEMENT •The if-else statement is used to perform two operations for a single condition. •The if-else statement is an extension to the if statement using which, we can perform two different operations, i.e., one is for the correctness of that condition, and the other is for the incorrectness of the condition.
  • 8. The syntax of the if-else statement is given below. if(expression){ //code to be executed if condition is true }else{ //code to be executed if condition is false }
  • 9.
  • 10. IF ELSE-IF LADDER STATEMENT The if-else-if ladder statement is an extension to the if-else statement.  It is used in the scenario where there are multiple cases to be performed for different conditions. In if-else-if ladder statement, if a condition is true then the statements defined in the if block will be executed, otherwise if some other condition is true then the statements defined in the else-if block will be executed, at the last if none of the condition is true then the statements defined in the else block will be executed.
  • 11.
  • 12.
  • 13. SWITCH STATEMENT •The switch statement in C is an alternate to if-else-if ladder statement which allows us to execute multiple operations for the different possibles values of a single variable called switch variable. •Here, We can define various statements in the multiple cases for the different values of a single variable.
  • 14.
  • 15.
  • 16. C LOOPS The looping can be defined as repeating the same process multiple times until a specific condition satisfies. Types of C Loops There are three types of loops in C language that is given below: •do while •while •for
  • 17. WHILE LOOP IN C A while loop in C programming repeatedly executes a target statement as long as a given condition is true. Syntax The syntax of a while loop in C programming language is − while(condition) { statement(s); }
  • 18.
  • 19. FOR LOOP IN C A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Syntax The syntax of a for loop in C programming language is − for ( init; condition; increment ) { statement(s); }
  • 20.
  • 21. DO...WHILE LOOP IN C •Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop. •A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time.
  • 22. The syntax of a do...while loop in C programming language is − do { statement(s); } while( condition ); Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested.
  • 23.
  • 24. C COMMENTS •Comments can be used to explain code, and to make it more readable. It can also be used to prevent execution when testing alternative code. •Comments can be singled-lined or multi-lined.
  • 25. SINGLE-LINE COMMENTS Single-line comments start with two forward slashes (//). Any text between // and the end of the line is ignored by the compiler (will not be executed). This example uses a single-line comment before a line of code: Example // This is a comment printf("Hello World!");
  • 26. C MULTI-LINE COMMENTS Multi-line comments start with /* and ends with */. Any text between /* and */ will be ignored by the compiler: Example /* The code below will print the words Hello World! to the screen, and it is amazing */ printf("Hello World!");