Your SlideShare is downloading. ×

Theory 4

336
views

Published on

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
336
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Theory # 4 Functions
  • 2.  
      • Functions
      • Returning a value from a function
      • Sending values to a functions
      • Arguments
      • External Variables
      • Prepocessor directives
  • 3. Functions
      • Avoiding Unnecessary Repetition of Code
      • Program Organization
  • 4. Simple Functions
      • Structure of Functions
      • The Function Definition
      • Calling the Function
      • Function Prototype (Declaration)
      • Local Variables
  • 5. Functions That Return a Value
      • The return Statement
      • Returning Type (int, float, etc)
      • Limitation of return()
    •  
  • 6. Using Arguments to Pass Data to a Function
      • Structure of Function Call with Arguments
      • Passing Variables as Arguments
      • Passing Multiple Arguments
  • 7. Using More Than One Function
    •  
  • 8. External Variables
    • int external_num;
    • void print(void);
    • void main(void)
    • {
    •      external_num = 9;
    •     print();
    •     
    • }
    • void print(void)
    • {
    •     printf("%d",external_num);
    • }
  • 9. Argument Names in the Declarator
    • void drawSquare(int , int);
    • void drawSquare(int width, int height);
  • 10. Proprocessor Directives
    • The #define Directive
    • #define PI3.14159
    • float area(float);
    • void main(void)
    • {
    •     printf("area of sphere is %.2f", area(3))
    • }
    • float area(float rad)
    • {
    •     return (4 * PI * rad * rad);  
    • }
  • 11.  
    • why use #define
    • why not use variable Names
    • The const Modifier
    •     const float PI = 3.141592;
  • 12. Macros
    • #define ERROR printf("nError.n");
    • #define PR(n) printf("%.2f",n);
    • void main(void)
    • {
    •     float num1 = 27.25;
    •     float num2;
    •      num2 = 1.0 / 3.0
    •     if(num1 > 2)
    •      {
    •         ERROR;
    •      }
    •     PR(num1);
    •      PR(num2);
    • }
  • 13. Macros and Functions
      • #define PI 3.14159
      • #define AREA(X) (4* PI * X * X);
      • #define SUM(x,y) (x+y);

×