Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Theory 4

336
views

Published on

Published in: Education, Technology

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

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

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(&quot;%d&quot;,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(&quot;area of sphere is %.2f&quot;, area(3))
• }
• {
• }
• 11.
• why use #define
• why not use variable Names
• The const Modifier
•     const float PI = 3.141592;
• 12. Macros
• #define ERROR printf(&quot;nError.n&quot;);
• #define PR(n) printf(&quot;%.2f&quot;,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);