SlideShare a Scribd company logo
1 of 21
conditional Statement
Presented by :
khwajaaghakarimy77@gmail.com
The topic we’ll present >>>
What conditional statements ?
What is Types conditional statements?
If statements with example
If else statement with example
Nested if with example
Switch
Loop
 What is conditional?
 The conditional statement are used to execute the or
(ignore) a set of statement after testing the a condition
 The condition statement are also called selection
statement
 Usage of conditional statement in life ?
 I am learning c, c++ I am confuse how it work in real life
 In programming each function have a reason
 Lets say about conditional statement
 A user going to signing up for Facebook bout we don't
want the users signing up of age less than 15 years old. If
user age is less than 15 it should terminate the sign up
page and give a reason saying
 “sorry your too Young”
 Here we use if else statement behind situation
If statement ?
 If statement is used to execute or ignore a set
of statement after testing the condition
 Syntax
 if(condition)
 Statement -1;
 Statement -2;
Program of If Statement?
If else statement ??
Program of If-else statement??
If –else statement example in real life??
 If it id raining I shall not water the plants , else I have
to water the plants.
 now we can write it in pseudo code
 If (raining == true)
 Do not water
 Else
 Do water
Nested if statement
Nested if
When an if statement is used within another if statement it is called nested
statement.
If the condition-1 is true then the control shift to the next if statement and
the condition-2 is tested
If the condition-2 is true then the statement-2 is execute
The control will pass to statement -3 and this statement will execute
If the condition-2 is false thestatement-2 is skipped and the control shift to
the statement-3 and it will execute.
Syntax:
If (condition-1)
{
If (condition-2)
{
statement-2
}
Conditon-3
Example of nested if in real life
If a boy age is more the 18
if his nationality was Afghan
than he can give the vote in election
now we change it in pseudo code
if (age>18)
{
if (nationality ==‘Afghan’)
cout<<“you Can Give the Voten”;
}
else
Cout<<“you can not give the vote”;
Program of nested if
 Void main()
 {
 In a,b,c;
 Cout<<“enter first valuen”;
 Cin>>a;
 Cout<<“enter the 2nd valuen”;
 Cin>>b;
 Cout<<“enter the 3rd valuen”
 Cin>>c;
 If(a==b)
 {
 If(a==c)
 Cout<<“these values are equaln”;
 }
 else
 cout<<“these value are differents”;
What is switch Statement ?
 Switch statement is use when a multiple choice are given
and one choice be selected.
 When the switch statement is executed the given
expression is first evaluate and then value returned by
the expression is compared with the values of the
constant given in each case if the value match with co-
 nstant value of a case then the statement of that case are
execute
 Keyword default is also used in the body of the switch if
no case matched then the statement default are execute
 Break statement
 Break statement is used to exit from the body of the
switch
example of switch in Real life ?
 Let a company allows you a family tour, but the budget is
not confirmed yet so, you would pre-plan the tour ? For
this based on number of family member ready for this
tour ,you would collect information for the tour expense
of different destination and later on, select which one
suits to your budget
What is syntax of switch Statement ?
 Switch(expression)
 {
 Case constant-1;
 Statements;
 Break;
 Case const-2;
 Statements;
 Break;
 Case const-3;
 Statements;
 Default
 Statements;
 }
Program of switch statement?
What is Loop?
Example of Loop in real life?
Intruduction conditional statement
Intruduction conditional statement

More Related Content

What's hot

Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
IMPROPER INTEGRAL
   IMPROPER INTEGRAL   IMPROPER INTEGRAL
IMPROPER INTEGRALkishan619
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++guestfb6ada
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statementRaj Parekh
 
Lesson 19 improper intergals
Lesson 19 improper intergalsLesson 19 improper intergals
Lesson 19 improper intergalsLawrence De Vera
 
Database normalization
Database normalizationDatabase normalization
Database normalizationAsar Theen
 
Linear regression interpretation
Linear regression interpretationLinear regression interpretation
Linear regression interpretationaswhite
 
Control statements and functions in c
Control statements and functions in cControl statements and functions in c
Control statements and functions in cvampugani
 
Conditional Statements - R.D.Sivakumar
Conditional Statements - R.D.SivakumarConditional Statements - R.D.Sivakumar
Conditional Statements - R.D.SivakumarSivakumar R D .
 
Basic Calculus Lesson 1
Basic Calculus Lesson 1Basic Calculus Lesson 1
Basic Calculus Lesson 1alicelagajino
 
Midterm 3 review
Midterm 3 reviewMidterm 3 review
Midterm 3 reviewdrahkos1
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statementFarshidKhan
 

What's hot (15)

Using decision statements
Using decision statementsUsing decision statements
Using decision statements
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
IMPROPER INTEGRAL
   IMPROPER INTEGRAL   IMPROPER INTEGRAL
IMPROPER INTEGRAL
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
 
Lesson 19 improper intergals
Lesson 19 improper intergalsLesson 19 improper intergals
Lesson 19 improper intergals
 
Normalization
NormalizationNormalization
Normalization
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Linear regression interpretation
Linear regression interpretationLinear regression interpretation
Linear regression interpretation
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Control statements and functions in c
Control statements and functions in cControl statements and functions in c
Control statements and functions in c
 
Conditional Statements - R.D.Sivakumar
Conditional Statements - R.D.SivakumarConditional Statements - R.D.Sivakumar
Conditional Statements - R.D.Sivakumar
 
Basic Calculus Lesson 1
Basic Calculus Lesson 1Basic Calculus Lesson 1
Basic Calculus Lesson 1
 
Midterm 3 review
Midterm 3 reviewMidterm 3 review
Midterm 3 review
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 

Viewers also liked

Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentationmazb786
 
Conditional and biconditional statements
Conditional and biconditional statementsConditional and biconditional statements
Conditional and biconditional statementsDannah Paquibot
 
Geometric Proofs
Geometric ProofsGeometric Proofs
Geometric Proofsdmidgette
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statementselissamiller
 
1st Test - If then, converse, inverse and contrapositive
1st Test - If then, converse, inverse and contrapositive1st Test - If then, converse, inverse and contrapositive
1st Test - If then, converse, inverse and contrapositiveBrandeis High School
 
Conditional statement
Conditional statementConditional statement
Conditional statementMaxie Santos
 
Conditional statements dkjfoafoiej
Conditional statements dkjfoafoiejConditional statements dkjfoafoiej
Conditional statements dkjfoafoiejmzzbarnes
 

Viewers also liked (11)

Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentation
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Conditional and biconditional statements
Conditional and biconditional statementsConditional and biconditional statements
Conditional and biconditional statements
 
Geometric Proofs
Geometric ProofsGeometric Proofs
Geometric Proofs
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Geometric Proofs
Geometric ProofsGeometric Proofs
Geometric Proofs
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
1st Test - If then, converse, inverse and contrapositive
1st Test - If then, converse, inverse and contrapositive1st Test - If then, converse, inverse and contrapositive
1st Test - If then, converse, inverse and contrapositive
 
Conditional statement
Conditional statementConditional statement
Conditional statement
 
Conditionals
ConditionalsConditionals
Conditionals
 
Conditional statements dkjfoafoiej
Conditional statements dkjfoafoiejConditional statements dkjfoafoiej
Conditional statements dkjfoafoiej
 

Similar to Intruduction conditional statement

What are conditional statements?
What are conditional statements?What are conditional statements?
What are conditional statements?AnuragSrivastava272
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.pptManojKhadilkar1
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loopssaifullahbhatti99
 
Compter pogramming and utilization
Compter pogramming and utilizationCompter pogramming and utilization
Compter pogramming and utilizationMaulik Sharma
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docxJavvajiVenkat
 
Decision control structures
Decision control structuresDecision control structures
Decision control structuresRahul Bathri
 
Programming (if else)
Programming (if else)Programming (if else)
Programming (if else)Papon Sarker
 
Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)Jagdish Kamble
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
Chapter 4(1)
Chapter 4(1)Chapter 4(1)
Chapter 4(1)TejaswiB4
 
4. decision making and some basic problem
4. decision making and some basic problem4. decision making and some basic problem
4. decision making and some basic problemAlamgir Hossain
 

Similar to Intruduction conditional statement (20)

What are conditional statements?
What are conditional statements?What are conditional statements?
What are conditional statements?
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Control structures in c
Control structures in cControl structures in c
Control structures in c
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loops
 
Compter pogramming and utilization
Compter pogramming and utilizationCompter pogramming and utilization
Compter pogramming and utilization
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
C Control Statements.docx
C Control Statements.docxC Control Statements.docx
C Control Statements.docx
 
Decision control structures
Decision control structuresDecision control structures
Decision control structures
 
Programming (if else)
Programming (if else)Programming (if else)
Programming (if else)
 
Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
Chapter 4(1)
Chapter 4(1)Chapter 4(1)
Chapter 4(1)
 
LOOPS AND DECISIONS
LOOPS AND DECISIONSLOOPS AND DECISIONS
LOOPS AND DECISIONS
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
 
4. decision making and some basic problem
4. decision making and some basic problem4. decision making and some basic problem
4. decision making and some basic problem
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 

Recently uploaded

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 

Recently uploaded (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 

Intruduction conditional statement

  • 1. conditional Statement Presented by : khwajaaghakarimy77@gmail.com
  • 2.
  • 3. The topic we’ll present >>> What conditional statements ? What is Types conditional statements? If statements with example If else statement with example Nested if with example Switch Loop
  • 4.  What is conditional?  The conditional statement are used to execute the or (ignore) a set of statement after testing the a condition  The condition statement are also called selection statement
  • 5.  Usage of conditional statement in life ?  I am learning c, c++ I am confuse how it work in real life  In programming each function have a reason  Lets say about conditional statement  A user going to signing up for Facebook bout we don't want the users signing up of age less than 15 years old. If user age is less than 15 it should terminate the sign up page and give a reason saying  “sorry your too Young”  Here we use if else statement behind situation
  • 6. If statement ?  If statement is used to execute or ignore a set of statement after testing the condition  Syntax  if(condition)  Statement -1;  Statement -2;
  • 7. Program of If Statement?
  • 9. Program of If-else statement??
  • 10. If –else statement example in real life??  If it id raining I shall not water the plants , else I have to water the plants.  now we can write it in pseudo code  If (raining == true)  Do not water  Else  Do water
  • 11. Nested if statement Nested if When an if statement is used within another if statement it is called nested statement. If the condition-1 is true then the control shift to the next if statement and the condition-2 is tested If the condition-2 is true then the statement-2 is execute The control will pass to statement -3 and this statement will execute If the condition-2 is false thestatement-2 is skipped and the control shift to the statement-3 and it will execute. Syntax: If (condition-1) { If (condition-2) { statement-2 } Conditon-3
  • 12. Example of nested if in real life If a boy age is more the 18 if his nationality was Afghan than he can give the vote in election now we change it in pseudo code if (age>18) { if (nationality ==‘Afghan’) cout<<“you Can Give the Voten”; } else Cout<<“you can not give the vote”;
  • 13. Program of nested if  Void main()  {  In a,b,c;  Cout<<“enter first valuen”;  Cin>>a;  Cout<<“enter the 2nd valuen”;  Cin>>b;  Cout<<“enter the 3rd valuen”  Cin>>c;  If(a==b)  {  If(a==c)  Cout<<“these values are equaln”;  }  else  cout<<“these value are differents”;
  • 14. What is switch Statement ?  Switch statement is use when a multiple choice are given and one choice be selected.  When the switch statement is executed the given expression is first evaluate and then value returned by the expression is compared with the values of the constant given in each case if the value match with co-  nstant value of a case then the statement of that case are execute  Keyword default is also used in the body of the switch if no case matched then the statement default are execute  Break statement  Break statement is used to exit from the body of the switch
  • 15. example of switch in Real life ?  Let a company allows you a family tour, but the budget is not confirmed yet so, you would pre-plan the tour ? For this based on number of family member ready for this tour ,you would collect information for the tour expense of different destination and later on, select which one suits to your budget
  • 16. What is syntax of switch Statement ?  Switch(expression)  {  Case constant-1;  Statements;  Break;  Case const-2;  Statements;  Break;  Case const-3;  Statements;  Default  Statements;  }
  • 17. Program of switch statement?
  • 19. Example of Loop in real life?