Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review for midterm exam Dilshad M. Shahid Spring NYU.

Similar presentations


Presentation on theme: "Review for midterm exam Dilshad M. Shahid Spring NYU."— Presentation transcript:

1 Review for midterm exam Dilshad M. Shahid Spring 1999 @ NYU

2 Today §Various topics in Chapters 2 - 5

3 Chapter 2 topics §variables - integers, floats, characters §variable declarations, assignment statements §main() §printf §scanf (remember the &, no output formatting) §format conversion string %d for integers, %f for floats, %c for characters

4 Chapter 2 topics §Memory concepts §destructive read-in, nondestructive read-out §precedence of arithmetic operators l () l *, / or % l + or - §Equality and relational operators, e.g. ==, !=, >=

5 Chapter 3 topics §Control structures goto is bad (leads to spaghetti code i.e. unstructured programming)

6 Chapter 3 topics §Selection structure l if l if/else l switch § If - all or nothing (only one option) §If/else - two options §Switch - many options §Can have multiple if/else statements to have more than two options §All switch statements can be rewritten as multiple if/else statements

7 Chapter 3 topics §Repetition structure l while l for § Use while when number of iterations is not known in advance §Use for when a fixed of iterations are to be made

8 Chapter 3 topics §Assignment operators, e.g. c += 3 l c += 3 corresponds to c = c + 3 l operators can be +, -, *, /, % §Increment/Decrement Operators, e.g. a++ l check out Fig 3.12 on page 80 in your text §Also check out Fig 3.14 for precedence of operators discussed up to Chapter 3

9 Chapter 4 topics §Counter controlled repetition §Sentinel controlled repetition §Switch in detail §Logical operators: &&, || and ! l Check out the truth tables for && and || §Fig 4.16 for operator precedence and associativity

10 Chapter 5 topics §Functions l definition (or body) l function prototype l general structure - input parameters, return variable l calling (or invoking) functions

11 Chapter 5 topics §Scope rules §Storage classes §Header files (standard and custom) §Call by value vs call by reference §Random Number Generation rand(), srand §Recursion l definition l recursion vs iteration


Download ppt "Review for midterm exam Dilshad M. Shahid Spring NYU."

Similar presentations


Ads by Google