Lesson 3 continued - PowerPoint PPT Presentation

About This Presentation
Title:

Lesson 3 continued

Description:

Lesson 3 continued Math and ... Evaluate me Order Of Operations* Try Me! Answer Answer Answer Lab 3.1 Easter Easter Try Me Easter Is this right? – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 18
Provided by: PaulL126
Category:

less

Transcript and Presenter's Notes

Title: Lesson 3 continued


1
Lesson 3 continued
  • Math and Incrementing

2
Evaluate me
  • How do you think we do this?
  • x 15 6 / 3

3
Order Of Operations
  • Level of Precedence Operator Associativity
  • Highest ()
  • unary - right to left
  • / left to right
  • Lowest - left to right
  • Just remember your Aunt Sally

4
Try Me!
  • (56)/(9-7)
  • 18 / 5 4 3
  • 1 3 5 - 2

5
Answer
  • (56)/(9-7) -gt 11/2 -gt 5

6
Answer
  • 18 / 5 4 3 -gt 3 4 3 -gt 12 3 -gt 0

7
Answer
  • 1 3 5 - 2 -gt 1 3 - 2 -gt 4 - 2 -gt 2

8
Lab 3.1 Easter
  • Divide y by 19 and call the remainder a. Ignore
    the quotient.
  • int a y 19

9
Easter Try Me
  • Divide b 8 by 25 and get a quotient f. Ignore
    the remainder.

10
Easter Is this right?
  • Divide b 8 by 25 and get a quotient f. Ignore
    the remainder.
  • Is this answer right or wrong?
  • int f b 8 / 25

11
Easter Correct Answer
  • Divide b 8 by 25 and get a quotient f. Ignore
    the remainder.
  • int f (b 8) / 25

12
Incrementing and Decrementing
  • You will soon see that it is very common to have
    to add amount to a number and save the new value.
  • int x 5x x 8 //Add 8 to x and save it
    in x

13
A Shortcut
  • Instead of
  • x x 8
  • Use can do this
  • x 8

14
Others Assignment Shortcuts
  • You can also do
  • -, , /,
  • Example
  • int x 100
  • x - 10
  • //after this, x will have the //value 90

15
Adding or Subtracting 1
  • Incrementing or Decrementing by 1 is very common,
    so we have an even better short cut
  • Instead of
  • x x 1
  • Or even
  • x 1
  • You can
  • x
  • Or
  • x
  • There is also a --
  • Example x--

16
Be Careful
  • x means add after everything else on this line
  • x means add before everything else on this line

17
Be Careful
  • int a1, b
  • b a
  • After execution of the above code
  • a 2 and b 2
  • int a1, b
  • b a
  •  After execution of the above code
  • a 2 and b 1
  •  
Write a Comment
User Comments (0)
About PowerShow.com