Conditional Statements in C+
+
Group Members
● Aima Rani
● Aqib Hussain
● Akash Hussain
● Arshad Hussain
● Ahtiram
● Aliyas Muhammad
● Arif Hussain
Topic:
Conditional
statements
● Conditional statements are
constructs used to perform
decision-making in
programming by executing
different code blocks based on
certain conditions.
Aima Rani Conditional
Statements
Importances
● Used in nearly all programming
scenarios (loops, functions,
error handling).
● If Coditional Statement
● IF-Else Conditonal Statement
● IF-Else-IF Conditional
statement
● Switch Conditional Statement
● Ternary Operator
Types of conditional
statements in C++:
What is if else statement?
● An if-else statement is a control structure
used in programming to execute different
blocks of code based on conditions or
decisions.
● If the condition is true, the code inside
the if block is executed.
● If the condition is false, the code inside
the else block is executed.
Aqib Hussain If else statement
Syntax of if else statement
What is if-else-if
statement?
● The if-else if statement allows for multiple
conditions to be checked in sequence. If the
if condition is false, the program checks the
next else if condition, and so on.
● In an else-if chain, If one condition is true,
the rest are skipped; otherwise, checking
continues until a true condition is found
Akash Hussain if-else-if
Syntax of if else if statement
What is Nested If Else?
● It is an if-else statement placed inside
another if or else block.
● It allows for more complex decision-
making by evaluating additional conditions
based on the outcome of the first
condition.
Arshad Hussain Nested if Else
Example:
output:
“Positive Even number”
What is a switch
statement?
● Allows selection among multiple fixed
options.
● In switch expressions, each block is
terminated by a break keyword.
● The statements in switch are expressed
with cases.
Ahtiram Switch statement
Example
“Wednesday”
Output
What are ternary
operators?
● The ternary operator is a shorthand way of
writing an if-else statement.
● It takes three operands: a condition, a
result for when the condition is true, and a
result for when the condition is false.
● Evaluates a condition; if true, executes
expression 1; otherwise, executes
expression 2.
Aliyas muhammad Ternary oprators
output:
“Adult”
Flow Chart
Arif Hussain Flow chart
Thank You

Conditional Statements . Ppt group presentation

  • 1.
    Conditional Statements inC+ + Group Members ● Aima Rani ● Aqib Hussain ● Akash Hussain ● Arshad Hussain ● Ahtiram ● Aliyas Muhammad ● Arif Hussain Topic:
  • 2.
    Conditional statements ● Conditional statementsare constructs used to perform decision-making in programming by executing different code blocks based on certain conditions. Aima Rani Conditional Statements Importances ● Used in nearly all programming scenarios (loops, functions, error handling). ● If Coditional Statement ● IF-Else Conditonal Statement ● IF-Else-IF Conditional statement ● Switch Conditional Statement ● Ternary Operator Types of conditional statements in C++:
  • 3.
    What is ifelse statement? ● An if-else statement is a control structure used in programming to execute different blocks of code based on conditions or decisions. ● If the condition is true, the code inside the if block is executed. ● If the condition is false, the code inside the else block is executed. Aqib Hussain If else statement Syntax of if else statement
  • 4.
    What is if-else-if statement? ●The if-else if statement allows for multiple conditions to be checked in sequence. If the if condition is false, the program checks the next else if condition, and so on. ● In an else-if chain, If one condition is true, the rest are skipped; otherwise, checking continues until a true condition is found Akash Hussain if-else-if Syntax of if else if statement
  • 5.
    What is NestedIf Else? ● It is an if-else statement placed inside another if or else block. ● It allows for more complex decision- making by evaluating additional conditions based on the outcome of the first condition. Arshad Hussain Nested if Else Example: output: “Positive Even number”
  • 6.
    What is aswitch statement? ● Allows selection among multiple fixed options. ● In switch expressions, each block is terminated by a break keyword. ● The statements in switch are expressed with cases. Ahtiram Switch statement Example “Wednesday” Output
  • 7.
    What are ternary operators? ●The ternary operator is a shorthand way of writing an if-else statement. ● It takes three operands: a condition, a result for when the condition is true, and a result for when the condition is false. ● Evaluates a condition; if true, executes expression 1; otherwise, executes expression 2. Aliyas muhammad Ternary oprators output: “Adult”
  • 8.
  • 9.