1 / 18

3-3 Side Effects

3-3 Side Effects.

benmathews
Download Presentation

3-3 Side Effects

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression on the right of the assignment operator and then places the value in the left variable. Changing the value of the left variable is a side effect. Computer Science: A Structured Programming Approach Using C

  2. 3-4 Evaluating Expressions Now that we have introduced the concepts of precedence, associativity, and side effects, let’s work through some examples. Topics discussed in this section: Expressions without Side Effects Expressions with Side Effects Computer Science: A Structured Programming Approach Using C

  3. PROGRAM 3-6 Evaluating Expressions Computer Science: A Structured Programming Approach Using C

  4. PROGRAM 3-6 Evaluating Expressions Computer Science: A Structured Programming Approach Using C

  5. PROGRAM 3-6 Evaluating Expressions Computer Science: A Structured Programming Approach Using C

  6. Warning Computer Science: A Structured Programming Approach Using C

  7. 3-5 Type Conversion Up to this point, we have assumed that all of our expressions involved data of the same type. But, what happens when we write an expression that involves two different data types, such as multiplying an integer and a floating-point number? To perform these evaluations, one of the types must be converted. Topics discussed in this section: Implicit Type Conversion Explicit Type Conversion (Cast) Computer Science: A Structured Programming Approach Using C

  8. FIGURE 3-10 Conversion Rank Computer Science: A Structured Programming Approach Using C

  9. PROGRAM 3-7 Implicit Type Conversion Computer Science: A Structured Programming Approach Using C

  10. PROGRAM 3-7 Implicit Type Conversion Computer Science: A Structured Programming Approach Using C

  11. PROGRAM 3-7 Implicit Type Conversion Computer Science: A Structured Programming Approach Using C

  12. PROGRAM 3-8 Explicit Casts Computer Science: A Structured Programming Approach Using C

  13. PROGRAM 3-8 Explicit Casts Computer Science: A Structured Programming Approach Using C

  14. PROGRAM 3-8 Explicit Casts Computer Science: A Structured Programming Approach Using C

  15. 3-6 Statements A statement causes an action to be performed by the program. It translates directly into one or more executable computer instructions. You may have noticed that we have used a semicolon at the end of the statements in our programs. Most statements need a semicolon at the end; some do not. Topics discussed in this section: Statement Type The Role of the Semicolon Statements and Defined Constants Computer Science: A Structured Programming Approach Using C

  16. FIGURE 3-11 Types of Statements Computer Science: A Structured Programming Approach Using C

  17. FIGURE 3-12 Compound Statement Computer Science: A Structured Programming Approach Using C

  18. Note The compound statement does not need a semicolon. Computer Science: A Structured Programming Approach Using C

More Related