IF Statement Control Flow
By: Mohammed Al-Janoubi
My Handout
https://goo.gl/GK8dg3
Main Objectives
 Identify IF statement in programming.
 Create IF statement Eclipse environment.
 Define logic gates.
 Apply logical gates in IF statement.
What is the if statement Control flow?
 The codes inside your source files are generally executed from top to bottom,
in the order that they appear. Control Flow statements break up the flow of
execution by employing conditions
 The most basic form of conditional control flow is the IF Statement, which
chooses whether to execute statements that follow it
IF Statement Diagram
Open Your Programming Environment
Logic Gates (AND)
The AND gate is so named because, if 0 is called "false" and 1 is called "true," the
gate acts in the same way as the logical "and" operator. The following illustration
and table show the circuit symbol and logic combinations for an AND gate. (In the
symbol, the input terminals are at left and the output terminal is at right.) The
output is "true" when both inputs are "true." Otherwise, the output is "false."
INPUT1 INPUT2 OUTPUT
T T T
T F F
F T F
F F F
Logic Gates (OR)
The OR gate gets its name from the fact that it behaves after the fashion of the
logical inclusive "or." The output is "true" if either or both of the inputs are "true."
If both inputs are "false," then the output is "false.“
INPUT1 INPUT2 OUTPUT
T T T
T F T
F T T
F F F
Activity
each group will draw both logic gates and their
truth tables
INPUT 1 INPUT 2 OUTPUT
T T ?
T F ?
F T ?
F T ?
Apply AND gate on IF statement
&& (Shift+7) use this symbol for AND gate
Syntax
if (condition1 && condition2) {
block of code to be executed if condition1 and
condition2 is true
} else {
block of code to be executed if only one condition
is false
}
Apply OR gate on IF statement
|| (Shift+) use this symbol for OR gate
Syntax
if (condition1 || condition2) {
block of code to be executed if condition1 or condition2
is true
} else {
block of code to be executed if only both condition is
false
}
Quizizz Activity
 Identify IF statement in programming.
 Create IF statement Eclipse environment.
 Define logic gates.
 Apply logical gates in IF statement.
Share Your Ideas to Improve My Lesson
https://goo.gl/z5ESrc

If statement control flow

  • 1.
    IF Statement ControlFlow By: Mohammed Al-Janoubi
  • 2.
  • 3.
    Main Objectives  IdentifyIF statement in programming.  Create IF statement Eclipse environment.  Define logic gates.  Apply logical gates in IF statement.
  • 4.
    What is theif statement Control flow?  The codes inside your source files are generally executed from top to bottom, in the order that they appear. Control Flow statements break up the flow of execution by employing conditions  The most basic form of conditional control flow is the IF Statement, which chooses whether to execute statements that follow it
  • 5.
  • 6.
  • 7.
    Logic Gates (AND) TheAND gate is so named because, if 0 is called "false" and 1 is called "true," the gate acts in the same way as the logical "and" operator. The following illustration and table show the circuit symbol and logic combinations for an AND gate. (In the symbol, the input terminals are at left and the output terminal is at right.) The output is "true" when both inputs are "true." Otherwise, the output is "false." INPUT1 INPUT2 OUTPUT T T T T F F F T F F F F
  • 8.
    Logic Gates (OR) TheOR gate gets its name from the fact that it behaves after the fashion of the logical inclusive "or." The output is "true" if either or both of the inputs are "true." If both inputs are "false," then the output is "false.“ INPUT1 INPUT2 OUTPUT T T T T F T F T T F F F
  • 9.
    Activity each group willdraw both logic gates and their truth tables INPUT 1 INPUT 2 OUTPUT T T ? T F ? F T ? F T ?
  • 10.
    Apply AND gateon IF statement && (Shift+7) use this symbol for AND gate Syntax if (condition1 && condition2) { block of code to be executed if condition1 and condition2 is true } else { block of code to be executed if only one condition is false }
  • 11.
    Apply OR gateon IF statement || (Shift+) use this symbol for OR gate Syntax if (condition1 || condition2) { block of code to be executed if condition1 or condition2 is true } else { block of code to be executed if only both condition is false }
  • 12.
  • 13.
     Identify IFstatement in programming.  Create IF statement Eclipse environment.  Define logic gates.  Apply logical gates in IF statement.
  • 16.
    Share Your Ideasto Improve My Lesson https://goo.gl/z5ESrc