SlideShare a Scribd company logo
Decision Making & Basic Programs
Md. Alamgir Hossain
Lecturer,
Dept. of CSE, Prime University
Mail: alamgir.cse14.just@gmail.com
Decision Making
There come situations in real life when we need to make some decisions and
based on these decisions, we decide what should we do next.
Similar situations arise in programming also where we need to make some
decisions and based on these decisions we will execute the next block of code.
Decision Making
Decision making statements in programming languages decide the direction of
flow of program execution. Decision making statements available in C or C++ are:
1. if statement
2. if..else statements
3. nested if statements
4. if-else-if ladder
5. switch statements
6. Jump Statements:
I. break
II. continue
III. goto
IV. return
If statement in C
if statement is the most simple decision making statement.
It is used to decide whether a certain statement or block of statements will be
executed or not i.e if a certain condition is true then a block of statement is
executed otherwise not.
Syntax:
Logic for checking whether a number is 5 or not
Input a number from user in some variable say number.
1. Check if(number == 5), then number is 5.
2. Check if(number != 5), then number is not 5.
C program to check whether a number is positive,
negative or zero
Simple program for if condition in C
Flow chart of if condition
Logic for checking whether a number is positive,
negative or zero
A number is said negative if it is less than 0 i.e. number < 0.
A number is said positive if it is greater than 0 i.e. number > 0.
We will use the above logic inside if to check number for negative, positive or zero.
Step by step descriptive logic to check negative, positive or zero.
Input a number from user in some variable say num.
1. Check if(number < 0), then number is negative.
2. Check if(number > 0), then number is positive.
3. Check if(number == 0), then number is zero.
C program to check whether a number is positive,
negative or zero
If-else statement in C
The if statement alone tells us that if a condition is true it will execute a block of
statements and if the condition is false it won’t.
But what if we want to do something else if the condition is false. Here comes the
C else statement. We can use the else statement with if statement to execute a
block of code when the condition is false.
Syntax:
Program for simple If-else statement in C
Flow-Chart of If-else statement
If-else-if ladder statement in C
Here, a user can decide among multiple options
Syntax:
Program for simple If-else-if statement in C
C program to check whether a number is positive,
negative or zero
C program to check a number is even/odd
Homework
1. Write a C program to check whether a number is divisible by 7 and 12 or not.
2. Write a C program to find the maximum between two numbers.
Thank You

More Related Content

What's hot

Intro to Pseudocode and Algorithms | Problem Solving in Computer Science
Intro to Pseudocode and Algorithms | Problem Solving in Computer ScienceIntro to Pseudocode and Algorithms | Problem Solving in Computer Science
Intro to Pseudocode and Algorithms | Problem Solving in Computer Science
Fru Louis
 
Lesson 19 improper intergals
Lesson 19 improper intergalsLesson 19 improper intergals
Lesson 19 improper intergals
Lawrence De Vera
 
IMPROPER INTEGRAL
   IMPROPER INTEGRAL   IMPROPER INTEGRAL
IMPROPER INTEGRAL
kishan619
 
Improper integral
Improper integralImproper integral
Improper integral
HardyJadav
 
Discrete Structure
Discrete Structure Discrete Structure
Discrete Structure
Syed Umair
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
Information Technology Center
 
Application of algorithm in real life
Application of algorithm in real lifeApplication of algorithm in real life
Application of algorithm in real life
Niloy Biswas
 
11 ml system design
11 ml system design11 ml system design
11 ml system design
TanmayVijay1
 
Decision structures chpt_5
Decision structures chpt_5Decision structures chpt_5
Decision structures chpt_5
cmontanez
 
Python breakdown-workbook
Python breakdown-workbookPython breakdown-workbook
Python breakdown-workbook
HARUN PEHLIVAN
 
Variables
VariablesVariables
Variables
Maha Saad
 
Python decision making part4
Python decision making part4Python decision making part4
Python decision making part4
Vishal Dutt
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
Tanveer Malik
 
12pointerin c#
12pointerin c#12pointerin c#
12pointerin c#
Sireesh K
 
Real numbers and their properties
Real numbers and their propertiesReal numbers and their properties
Real numbers and their properties
elearningunit2013
 
Javascript breakdown-workbook
Javascript breakdown-workbookJavascript breakdown-workbook
Javascript breakdown-workbook
HARUN PEHLIVAN
 
Doppl development iteration #5
Doppl development   iteration #5Doppl development   iteration #5
Doppl development iteration #5
Diego Perini
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
lemonmichelangelo
 
JetBrains MPS: Editor Aspect
JetBrains MPS: Editor AspectJetBrains MPS: Editor Aspect
JetBrains MPS: Editor Aspect
Mikhail Barash
 
Lesson 5 php operators
Lesson 5   php operatorsLesson 5   php operators
Lesson 5 php operators
MLG College of Learning, Inc
 

What's hot (20)

Intro to Pseudocode and Algorithms | Problem Solving in Computer Science
Intro to Pseudocode and Algorithms | Problem Solving in Computer ScienceIntro to Pseudocode and Algorithms | Problem Solving in Computer Science
Intro to Pseudocode and Algorithms | Problem Solving in Computer Science
 
Lesson 19 improper intergals
Lesson 19 improper intergalsLesson 19 improper intergals
Lesson 19 improper intergals
 
IMPROPER INTEGRAL
   IMPROPER INTEGRAL   IMPROPER INTEGRAL
IMPROPER INTEGRAL
 
Improper integral
Improper integralImproper integral
Improper integral
 
Discrete Structure
Discrete Structure Discrete Structure
Discrete Structure
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
Application of algorithm in real life
Application of algorithm in real lifeApplication of algorithm in real life
Application of algorithm in real life
 
11 ml system design
11 ml system design11 ml system design
11 ml system design
 
Decision structures chpt_5
Decision structures chpt_5Decision structures chpt_5
Decision structures chpt_5
 
Python breakdown-workbook
Python breakdown-workbookPython breakdown-workbook
Python breakdown-workbook
 
Variables
VariablesVariables
Variables
 
Python decision making part4
Python decision making part4Python decision making part4
Python decision making part4
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
12pointerin c#
12pointerin c#12pointerin c#
12pointerin c#
 
Real numbers and their properties
Real numbers and their propertiesReal numbers and their properties
Real numbers and their properties
 
Javascript breakdown-workbook
Javascript breakdown-workbookJavascript breakdown-workbook
Javascript breakdown-workbook
 
Doppl development iteration #5
Doppl development   iteration #5Doppl development   iteration #5
Doppl development iteration #5
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
JetBrains MPS: Editor Aspect
JetBrains MPS: Editor AspectJetBrains MPS: Editor Aspect
JetBrains MPS: Editor Aspect
 
Lesson 5 php operators
Lesson 5   php operatorsLesson 5   php operators
Lesson 5 php operators
 

Similar to 4. decision making and some basic problem

C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docx
JavvajiVenkat
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
MuhammadBakri13
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loops
saifullahbhatti99
 
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdf
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdfLesson 2 C STATEMENT IN PROGRAMMING (M).pdf
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdf
WeejMaderazo
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Muhammad Hammad Waseem
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Ch04
Ch04Ch04
Chap 4 c++
Chap 4 c++Chap 4 c++
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
Chandrakant Divate
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection Statements
SzeChingChen
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
baabtra.com - No. 1 supplier of quality freshers
 
PRESENTATION.pptx
PRESENTATION.pptxPRESENTATION.pptx
PRESENTATION.pptx
MahrAlyanYousafwasli
 
Control All
Control AllControl All
Control All
phanleson
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
FarshidKhan
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
chintupro9
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdf
AbenezerAsefa1
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
Rakesh Roshan
 
basic of desicion control statement in python
basic of  desicion control statement in pythonbasic of  desicion control statement in python
basic of desicion control statement in python
nitamhaske
 

Similar to 4. decision making and some basic problem (20)

C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docx
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loops
 
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdf
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdfLesson 2 C STATEMENT IN PROGRAMMING (M).pdf
Lesson 2 C STATEMENT IN PROGRAMMING (M).pdf
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Ch04
Ch04Ch04
Ch04
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection Statements
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
PRESENTATION.pptx
PRESENTATION.pptxPRESENTATION.pptx
PRESENTATION.pptx
 
Control All
Control AllControl All
Control All
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdf
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
basic of desicion control statement in python
basic of  desicion control statement in pythonbasic of  desicion control statement in python
basic of desicion control statement in python
 

More from Alamgir Hossain

Malware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptxMalware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptx
Alamgir Hossain
 
5 nested if in c with proper example
5 nested if in c with proper example5 nested if in c with proper example
5 nested if in c with proper example
Alamgir Hossain
 
3. user input and some basic problem
3. user input and some basic problem3. user input and some basic problem
3. user input and some basic problem
Alamgir Hossain
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
Alamgir Hossain
 
1. importance of c
1. importance of c1. importance of c
1. importance of c
Alamgir Hossain
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android projectReport on student-faculty document sharing android project
Report on student-faculty document sharing android project
Alamgir Hossain
 
A lab report on modeling and simulation with python code
A lab report on modeling and simulation with python codeA lab report on modeling and simulation with python code
A lab report on modeling and simulation with python code
Alamgir Hossain
 
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Alamgir Hossain
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
Alamgir Hossain
 
Microsoft Teams
Microsoft TeamsMicrosoft Teams
Microsoft Teams
Alamgir Hossain
 

More from Alamgir Hossain (12)

Malware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptxMalware Detection Approaches using Data Mining Techniques.pptx
Malware Detection Approaches using Data Mining Techniques.pptx
 
5 nested if in c with proper example
5 nested if in c with proper example5 nested if in c with proper example
5 nested if in c with proper example
 
3. user input and some basic problem
3. user input and some basic problem3. user input and some basic problem
3. user input and some basic problem
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
 
1. importance of c
1. importance of c1. importance of c
1. importance of c
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android projectReport on student-faculty document sharing android project
Report on student-faculty document sharing android project
 
A lab report on modeling and simulation with python code
A lab report on modeling and simulation with python codeA lab report on modeling and simulation with python code
A lab report on modeling and simulation with python code
 
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
Lab report on to plot efficiency of pure and slotted aloha in matlab a data c...
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
 
Microsoft Teams
Microsoft TeamsMicrosoft Teams
Microsoft Teams
 

Recently uploaded

Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
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
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
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
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
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
 
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
 
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
 

Recently uploaded (20)

Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
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
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
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
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
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
 
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
 
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
 

4. decision making and some basic problem

  • 1. Decision Making & Basic Programs Md. Alamgir Hossain Lecturer, Dept. of CSE, Prime University Mail: alamgir.cse14.just@gmail.com
  • 2. Decision Making There come situations in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations arise in programming also where we need to make some decisions and based on these decisions we will execute the next block of code.
  • 3. Decision Making Decision making statements in programming languages decide the direction of flow of program execution. Decision making statements available in C or C++ are: 1. if statement 2. if..else statements 3. nested if statements 4. if-else-if ladder 5. switch statements 6. Jump Statements: I. break II. continue III. goto IV. return
  • 4. If statement in C if statement is the most simple decision making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not. Syntax:
  • 5. Logic for checking whether a number is 5 or not Input a number from user in some variable say number. 1. Check if(number == 5), then number is 5. 2. Check if(number != 5), then number is not 5.
  • 6. C program to check whether a number is positive, negative or zero
  • 7. Simple program for if condition in C
  • 8. Flow chart of if condition
  • 9. Logic for checking whether a number is positive, negative or zero A number is said negative if it is less than 0 i.e. number < 0. A number is said positive if it is greater than 0 i.e. number > 0. We will use the above logic inside if to check number for negative, positive or zero. Step by step descriptive logic to check negative, positive or zero. Input a number from user in some variable say num. 1. Check if(number < 0), then number is negative. 2. Check if(number > 0), then number is positive. 3. Check if(number == 0), then number is zero.
  • 10. C program to check whether a number is positive, negative or zero
  • 11. If-else statement in C The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the C else statement. We can use the else statement with if statement to execute a block of code when the condition is false. Syntax:
  • 12. Program for simple If-else statement in C
  • 14. If-else-if ladder statement in C Here, a user can decide among multiple options Syntax:
  • 15. Program for simple If-else-if statement in C
  • 16. C program to check whether a number is positive, negative or zero
  • 17. C program to check a number is even/odd
  • 18. Homework 1. Write a C program to check whether a number is divisible by 7 and 12 or not. 2. Write a C program to find the maximum between two numbers.