1 / 17

Chapter 4 Functions Instructor: Bindra Shrestha University of Houston – Clear Lake

Chapter 4 Functions Instructor: Bindra Shrestha University of Houston – Clear Lake. Acknowledgement Structured Programming Approach Using C By Behrouz A. Forouzan and Richard F. Gilberg. Function Modules. Function calls. Parameters and Return. Void Parameter and Void Return.

pauldbrown
Download Presentation

Chapter 4 Functions Instructor: Bindra Shrestha University of Houston – Clear Lake

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. Chapter 4 Functions Instructor: Bindra Shrestha University of Houston – Clear Lake

  2. Acknowledgement Structured Programming Approach Using C By Behrouz A. Forouzan and Richard F. Gilberg

  3. Function Modules

  4. Function calls

  5. Parameters and Return

  6. Void Parameter and Void Return

  7. Pass by Value, Return Void

  8. Pass by Value

  9. Function Defination

  10. Passing two values by copy A compound assignment is a shorthand notation for a simple assignment. Compound assignment operators are: *=, /=, %=, +=, and -= For example:For x*=y, equivalent simple expression is: x = x * y Similarly, x /= y is x = x/y x -= y+ 4 is x = x- ( y+ 4) x %= y is x = x % y x *= y+2 is x = x* ( y+ 2).

  11. The postfix increment/decrement operates at the second level of the Precedence Table ( see inside front cover) a ++ Here a is an operand while ++ is a postfix operator. a++ has the same effect as a =a+1. Although the result of both expression is the same, there is a major difference.For example: If variable a contains 4 before the expression is evaluated, the value of the expression a ++ is 4 After the evaluating the expression and its side effects, then only a becomes 5.

  12. Different ways of calling #include <stdio.h> int main (void) /* example of Postfix increment*/ { int a; a = 5; printf("%d\t", a); printf("%d\t", a++); printf("%d\n", a); return 0; } /* Results: 5 5 6 */

  13. One-way communication

  14. Two-way communication

  15. Two-way swapping values example

  16. Mixed communication

  17. Variable Scopes

More Related