Logic - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Logic

Description:

Logic. Relational and Equality Operators. Operator Condition Value ... case c': printf('Cruise'); break; case p': printf('Park'); break; default: printf('Work' ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 8
Provided by: neo69
Category:
Tags: case | logic | net

less

Transcript and Presenter's Notes

Title: Logic


1
Logic
2
Relational and Equality Operators
  • Operator Condition Value
  • lt xlty 1 (true)
  • gt xgty 0 (false)
  • lt zltw 1 (true)
  • gt xgtw 0 (false)
  • yy 1 (true)
  • ! w!z 1 (true)
  • x5, y7, za, wz

3
Logical Operators
  • (and)
  • 1 1 1 (true)
  • 1 0, 0 1 0 (false)
  • (or)
  • 1 1, 1 0, 0 1 1 (true)
  • 0 0 0 (false)
  • ! (not)
  • !1 0 (false)
  • !0 1 (true)

4
Operator Precedence
  • Ordered from high to low
  • !, , -,
  • , /,
  • , -
  • lt, lt, gt, gt
  • , !

5
The if Statement
  • if(21 gt 50)
  • printf(This is impossible)
  • else if(a Y)
  • printf(This is impossible)
  • else
  • printf(This is the only alternative)

6
Nested if Statements
  • if((75lt50)(1212))
  • printf(1)
  • if(((glty)(5!8))(17lt20))
  • printf(2)
  • else
  • printf(3)
  • else
  • printf(4)

7
The switch Statement
  • vacationType c
  • switch(vacationType)
  • case b
  • case B
  • printf(Beach)
  • break
  • case c
  • printf(Cruise)
  • break
  • case p
  • printf(Park)
  • break
  • default
  • printf(Work)
Write a Comment
User Comments (0)
About PowerShow.com