Conditional statements - PowerPoint PPT Presentation

About This Presentation
Title:

Conditional statements

Description:

The statements executed depend on a condition. Note the basic forms ... if ( (fido != null) && (fido.isAlive() ) { fido.bark(); if (score = 90) { grade = 'A' ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 3
Provided by: davidmutch
Category:

less

Transcript and Presenter's Notes

Title: Conditional statements


1
Conditional statements
  • The statements executed depend on a condition
  • Note the basic forms and punctuation
  • if (condition)
  • statement
  • statement
  • ...
  • if (condition)
  • statement
  • ...
  • else
  • statement
  • ...

if (naomi.winsRace()) count
if (x lt y) min x else min y
2
Conditional statements
  • The statements executed depend on a condition
  • The condition is evaluated left-to-right and may
    be short-circuited
  • Note the indentation and curly-brace style in
    multiple cases

if (x lt y) min x else min y
if (score gt 90) grade A else if
(score gt 80) grade B else
grade C
if (naomi.winsRace()) count
if ( (fido ! null) (fido.isAlive() )
fido.bark()
Questions?
Write a Comment
User Comments (0)
About PowerShow.com