SlideShare a Scribd company logo
Chapter 4
Function
                              Mr.Warawut Khangkhan
                 Twitter: http://twitter.com/awarawut
      Facebook: http://www.facebook.com/AjWarawut
                       E-Mail: awarawut@hotmail.com
                                 Mobile: 083-0698-410
Contents
 Binary function or Standard function.
 User defined function.
 Format function declaration.
 Type of functions.
 The score of variables.




             Mr.Warawut Khangkhan   Chapter 4 Function   2
FUNCTION




   Mr.Warawut Khangkhan   Chapter 4 Function   3
Function
               F           F F
 main( )           F   F                                 F

    F      C         F F2
   F (Library Function)                                F   F
    F             F   F F F                          (User
 Defined Function)




             Mr.Warawut Khangkhan   Chapter 4 Function         4
BINARY FUNCTION OR
STANDARD FUNCTION




   Mr.Warawut Khangkhan   Chapter 4 Function   5
Binary function or Standard
function
            F               F F                           C
        F           F   F              F                            F   F
                                  ,F       F                                F
                F
    F




                        Mr.Warawut Khangkhan   Chapter 4 Function               6
Binary function or Standard
function (Cont.)
          F       C                       F                F         .h
     F header file F                                           F
        F header file                          F                F
                  F                 F                  F       math.h
   F                F                              F              F string.h




             Mr.Warawut Khangkhan       Chapter 4 Function                     7
Binary function or Standard
function (Cont.)
         F         F   F
 #include <header file> F F
     F            C F F
       F      F      F header file                            F
           F    F                F                                F
             F F                                          F




              Mr.Warawut Khangkhan   Chapter 4 Function               8
Example lib_func.c
#include <stdio.h>
#include <math.h>
int main( ) {
   int x, y;
   printf(“Enter number: “);
   scanf(“%d”, &x);
   y = sqrt(x);
   printf(“Square root of %d = %d”, x, y);
    system(“PAUSE”);
    return 0;
}
                 Mr.Warawut Khangkhan   Chapter 4 Function   9
USER DEFINED
FUNCTION




   Mr.Warawut Khangkhan   Chapter 4 Function   10
F    F
(User defined function)
                      F                  C                   F         F
                                                         F                     F
      F F                 F                              C                 F       F           F
                  F           F
  F                                               F      F        F
       F                                                              F F F            F   F
            F F                               F




                                  Mr.Warawut Khangkhan   Chapter 4 Function                        11
User defined function (Cont.)
                      (Cont.)
    F       F                  F                                    F
                                      F                     FF          F
                    F                                                       F
        F       F




                        Mr.Warawut Khangkhan   Chapter 4 Function               12
FORMAT FUNCTION
DECLARATION




   Mr.Warawut Khangkhan   Chapter 4 Function   13
F      C
    (Format function declaration)
type function-name ( type arg-1, type arg-2, … ) {
    local variable declaration;
    statement-1;
    statement-2;
    statement-3;
    …
    statement-n;
    return ( value );
}


                    Mr.Warawut Khangkhan   Chapter 4 Function   14
Example ex_func.c
#include <stdio.h>            void main( ) {
                                line( );
void line( ) {
  int i;                        printf(“Welcome to
  for (i=0; i<30; i++)          C Programmingn”);
     printf(“*”);               line( );
  printf(“n”);                }
}



                Mr.Warawut Khangkhan   Chapter 4 Function   15
TYPE OF FUNCTIONS




   Mr.Warawut Khangkhan   Chapter 4 Function   16
F
(Type of functions)
           F                      F F3
   F   F              / F F
   F                 F F               F
   F           F F                            F




                     Mr.Warawut Khangkhan   Chapter 4 Function   17
F                F            / F F
                         F      F F                                     F F    F
        F             F (Argument)                      F           F              F
                F             F     F F                         F                          F
F                   F            FF                         F            F F           F
            F




                             Mr.Warawut Khangkhan   Chapter 4 Function                         18
F                         F
                        F                           F        F               F F
         F            F (Argument)                       F          F              F
         F             F F F                    F                         F   F
             F              F F F               F3                 int, float
int                       F       F              F F F                                 F
                                    F       F                    F F F
 F               int, float       int




                           Mr.Warawut Khangkhan         Chapter 4 Function                 19
F                               F F                                                 F
    F                         F F                          F
    F         F                F                 F F           F                                F
                      F                      F                          F               F
        F F                              F             F                                    F       F
                  F       F          F




                                    Mr.Warawut Khangkhan           Chapter 4 Function                   20
F          F F                                     F
(Cont.)
   variable = function-name ( arg-1, arg-2,
 … );
 F      F F          F   F F    return
      F        F       F




             Mr.Warawut Khangkhan   Chapter 4 Function   21
THE SCORE OF
VARIABLES




   Mr.Warawut Khangkhan   Chapter 4 Function   22
(The score of variables)
            C       F                                 F       F
     F          2
 ◦       global
 ◦       local




                  Mr.Warawut Khangkhan   Chapter 4 Function       23
global
    global                    F           F              external
                                  F       F                 F
                F             global F
      F   F F               F        F                     F
                    F               F F F F                    F
F




             Mr.Warawut Khangkhan   Chapter 4 Function              24
global (Cont.)
   F               global
    F                                                F
global             F             F




         Mr.Warawut Khangkhan   Chapter 4 Function       25
local
          local                      F          F
automatic                                               F                                           F
                F                   local                       F                   F
  F         F                           F                   F                               F
              F                       F             F                   F               F
          local     F                                               F           F
    F                                              F                                            F
        F               F       F              local                        F
      F


                        Mr.Warawut Khangkhan   Chapter 4 Function                                       26

More Related Content

PDF
การใช้งานโปรแกรม R เบื้องต้น
PDF
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
PDF
โครงสร้างภาษาซี2
PDF
พื้นฐานการออกแบบโปรแกรม
PDF
โครงสร้างภาษาซี1
PDF
ระบบน้ำเหลืองกับภูมิคุ้มกัน
PDF
การจัดการเรียนการสอน
PDF
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
การใช้งานโปรแกรม R เบื้องต้น
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
โครงสร้างภาษาซี2
พื้นฐานการออกแบบโปรแกรม
โครงสร้างภาษาซี1
ระบบน้ำเหลืองกับภูมิคุ้มกัน
การจัดการเรียนการสอน
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)

What's hot (20)

PDF
การขับถ่ายของสัตว์
PDF
การกำหนดตัวแปร
PDF
โครงสร้างภาษาซี
PDF
ธรรมชาติของสิ่งมีชีวิต
PDF
ระบบหมุนเวียน
PDF
1 โลกและการเปลี่ยนแปลง
PDF
C Language Program
PDF
Business Computer Project 4
PDF
เขียนโปรแกรมใช้คำสั่ง Printf scanf
PDF
สุดยอดความสำเร็จขององค์กร
PDF
Personality test
PDF
Microsoft word ใบความรู้การย่อยอาหารของคน
PDF
Microsoft word เกมบิงโกสัตว์
PDF
แบบฝึกทักษะการเขียนโปรแกรมภาษาซีเล่ม2
PDF
สารและสมบัติของสารและการจำแนก
PDF
การย่อยอาหารของคน
PDF
นิเวศวิทยา
PDF
Chemical management procedure [th]
PDF
ใบความรู้เรื่องคำสั่ง Printf scanf
PDF
2554-7.strategy of-most
การขับถ่ายของสัตว์
การกำหนดตัวแปร
โครงสร้างภาษาซี
ธรรมชาติของสิ่งมีชีวิต
ระบบหมุนเวียน
1 โลกและการเปลี่ยนแปลง
C Language Program
Business Computer Project 4
เขียนโปรแกรมใช้คำสั่ง Printf scanf
สุดยอดความสำเร็จขององค์กร
Personality test
Microsoft word ใบความรู้การย่อยอาหารของคน
Microsoft word เกมบิงโกสัตว์
แบบฝึกทักษะการเขียนโปรแกรมภาษาซีเล่ม2
สารและสมบัติของสารและการจำแนก
การย่อยอาหารของคน
นิเวศวิทยา
Chemical management procedure [th]
ใบความรู้เรื่องคำสั่ง Printf scanf
2554-7.strategy of-most
Ad

Similar to Function C (20)

PDF
Session and Cookie
PDF
Index with Word 2007
PDF
Brief create list-km090354
PDF
การออกแบบและพัฒนาเว็บไซต์
PDF
Database Design
PDF
Ch01 introduction-web
PDF
พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์
PDF
การใช้เครื่องมือ (Tools) พื้นฐานในโปรแกรม Adobe Photoshop CS3 ที่มา http://...
PDF
กล้องจุลทรรศน์
PDF
กล้องจุลทรรศน์
PDF
Serial controldoc190154
PDF
คู่มือโปรแกรม Book mark2551
PDF
Flash unit 1
PDF
Object-Oriented Programming 7
PDF
Object-Oriented Programming 8
PDF
Display Table Demo
PDF
Object-Oriented Programming 9
PDF
กลุ่ม3
PDF
Login
PDF
Object-Oriented Programming 10
Session and Cookie
Index with Word 2007
Brief create list-km090354
การออกแบบและพัฒนาเว็บไซต์
Database Design
Ch01 introduction-web
พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์
การใช้เครื่องมือ (Tools) พื้นฐานในโปรแกรม Adobe Photoshop CS3 ที่มา http://...
กล้องจุลทรรศน์
กล้องจุลทรรศน์
Serial controldoc190154
คู่มือโปรแกรม Book mark2551
Flash unit 1
Object-Oriented Programming 7
Object-Oriented Programming 8
Display Table Demo
Object-Oriented Programming 9
กลุ่ม3
Login
Object-Oriented Programming 10
Ad

More from Warawut (20)

PDF
Database design
PDF
Object-Oriented Programming 6
PDF
Management Information System 6
PDF
Management Information System 5
PDF
Management Information System 4
PDF
Object-Oriented Programming 5
PDF
Business Computer Project 3
PDF
Management Information System 3
PDF
Business Computer Project 2
PDF
Chapter 2 Strategy & Information System
PDF
Object-Oriented Programming 4
PDF
Business Computer Project 1
PDF
Chapter 1 Organization & MIS
PDF
Object-Oriented Programming 3
PDF
Object-Oriented Programming 2
PDF
Object-Oriented Programming 1
PDF
Upload File
PDF
Form Validation
PDF
Tips & Track
PDF
Edit & Delete Data
Database design
Object-Oriented Programming 6
Management Information System 6
Management Information System 5
Management Information System 4
Object-Oriented Programming 5
Business Computer Project 3
Management Information System 3
Business Computer Project 2
Chapter 2 Strategy & Information System
Object-Oriented Programming 4
Business Computer Project 1
Chapter 1 Organization & MIS
Object-Oriented Programming 3
Object-Oriented Programming 2
Object-Oriented Programming 1
Upload File
Form Validation
Tips & Track
Edit & Delete Data

Recently uploaded (20)

DOCX
FIFA 2026 Tickets The Main Favorites to Win the FIFA World Cup 2026.docx
DOCX
NFL London Jets QB Room Dealing with Multiple Injuries.docx
PDF
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
PPTX
International Football (International football is a type of soccer in which n...
PPTX
India – The Diverse and Dynamic Country | TIDA Sports
DOCX
FIFA World Cup Semi Final: Lionel Messi one win from crowning glory after Arg...
PPTX
Best All-Access Digital Pass me .pptxxxx
PDF
Women Rugby World Cup 2025 Tickets: Ireland’s Road to Redemption, Squad Named...
PPTX
Badminton Sport group presentation pathfit
DOCX
FA Cup Final 2026 Siring: Arne Slot Crit
PDF
Download GTA 5 For PC (Windows 7, 10, 11)
PDF
FIFA World Cup Scaloni Hopeful for Messi’s FIFA World Cup 2026 Participation.pdf
DOCX
NFL Dublin Addison Returns Home To Haunt Pittsburgh.docx
DOCX
NFL Dublin Labriola on Steelers’ Victory Over the Jaguars.docx
PPT
Aboriginals Achievements in Society and Community Development
PPTX
ttttttttttttttttttttttttarget games.pptx
DOCX
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
PDF
FIFA World Cup Semi Final Los Angeles is a Global Soccer Powerhouse for the F...
DOC
Bishop's毕业证学历认证,维耶蒙特利尔学校毕业证毕业证文凭
PDF
BOOK MUAYTHAI THAI FIGHT ALEXANDRE BRECK
FIFA 2026 Tickets The Main Favorites to Win the FIFA World Cup 2026.docx
NFL London Jets QB Room Dealing with Multiple Injuries.docx
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
International Football (International football is a type of soccer in which n...
India – The Diverse and Dynamic Country | TIDA Sports
FIFA World Cup Semi Final: Lionel Messi one win from crowning glory after Arg...
Best All-Access Digital Pass me .pptxxxx
Women Rugby World Cup 2025 Tickets: Ireland’s Road to Redemption, Squad Named...
Badminton Sport group presentation pathfit
FA Cup Final 2026 Siring: Arne Slot Crit
Download GTA 5 For PC (Windows 7, 10, 11)
FIFA World Cup Scaloni Hopeful for Messi’s FIFA World Cup 2026 Participation.pdf
NFL Dublin Addison Returns Home To Haunt Pittsburgh.docx
NFL Dublin Labriola on Steelers’ Victory Over the Jaguars.docx
Aboriginals Achievements in Society and Community Development
ttttttttttttttttttttttttarget games.pptx
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
FIFA World Cup Semi Final Los Angeles is a Global Soccer Powerhouse for the F...
Bishop's毕业证学历认证,维耶蒙特利尔学校毕业证毕业证文凭
BOOK MUAYTHAI THAI FIGHT ALEXANDRE BRECK

Function C

  • 1. Chapter 4 Function Mr.Warawut Khangkhan Twitter: http://twitter.com/awarawut Facebook: http://www.facebook.com/AjWarawut E-Mail: awarawut@hotmail.com Mobile: 083-0698-410
  • 2. Contents Binary function or Standard function. User defined function. Format function declaration. Type of functions. The score of variables. Mr.Warawut Khangkhan Chapter 4 Function 2
  • 3. FUNCTION Mr.Warawut Khangkhan Chapter 4 Function 3
  • 4. Function F F F main( ) F F F F C F F2 F (Library Function) F F F F F F F (User Defined Function) Mr.Warawut Khangkhan Chapter 4 Function 4
  • 5. BINARY FUNCTION OR STANDARD FUNCTION Mr.Warawut Khangkhan Chapter 4 Function 5
  • 6. Binary function or Standard function F F F C F F F F F F ,F F F F F Mr.Warawut Khangkhan Chapter 4 Function 6
  • 7. Binary function or Standard function (Cont.) F C F F .h F header file F F F header file F F F F F math.h F F F F string.h Mr.Warawut Khangkhan Chapter 4 Function 7
  • 8. Binary function or Standard function (Cont.) F F F #include <header file> F F F C F F F F F header file F F F F F F F F Mr.Warawut Khangkhan Chapter 4 Function 8
  • 9. Example lib_func.c #include <stdio.h> #include <math.h> int main( ) { int x, y; printf(“Enter number: “); scanf(“%d”, &x); y = sqrt(x); printf(“Square root of %d = %d”, x, y); system(“PAUSE”); return 0; } Mr.Warawut Khangkhan Chapter 4 Function 9
  • 10. USER DEFINED FUNCTION Mr.Warawut Khangkhan Chapter 4 Function 10
  • 11. F F (User defined function) F C F F F F F F F C F F F F F F F F F F F F F F F F F F Mr.Warawut Khangkhan Chapter 4 Function 11
  • 12. User defined function (Cont.) (Cont.) F F F F F FF F F F F F Mr.Warawut Khangkhan Chapter 4 Function 12
  • 13. FORMAT FUNCTION DECLARATION Mr.Warawut Khangkhan Chapter 4 Function 13
  • 14. F C (Format function declaration) type function-name ( type arg-1, type arg-2, … ) { local variable declaration; statement-1; statement-2; statement-3; … statement-n; return ( value ); } Mr.Warawut Khangkhan Chapter 4 Function 14
  • 15. Example ex_func.c #include <stdio.h> void main( ) { line( ); void line( ) { int i; printf(“Welcome to for (i=0; i<30; i++) C Programmingn”); printf(“*”); line( ); printf(“n”); } } Mr.Warawut Khangkhan Chapter 4 Function 15
  • 16. TYPE OF FUNCTIONS Mr.Warawut Khangkhan Chapter 4 Function 16
  • 17. F (Type of functions) F F F3 F F / F F F F F F F F F F Mr.Warawut Khangkhan Chapter 4 Function 17
  • 18. F F / F F F F F F F F F F (Argument) F F F F F F F F F F F FF F F F F F Mr.Warawut Khangkhan Chapter 4 Function 18
  • 19. F F F F F F F F F (Argument) F F F F F F F F F F F F F F F3 int, float int F F F F F F F F F F F F int, float int Mr.Warawut Khangkhan Chapter 4 Function 19
  • 20. F F F F F F F F F F F F F F F F F F F F F F F F F F F F Mr.Warawut Khangkhan Chapter 4 Function 20
  • 21. F F F F (Cont.) variable = function-name ( arg-1, arg-2, … ); F F F F F F return F F F Mr.Warawut Khangkhan Chapter 4 Function 21
  • 22. THE SCORE OF VARIABLES Mr.Warawut Khangkhan Chapter 4 Function 22
  • 23. (The score of variables) C F F F F 2 ◦ global ◦ local Mr.Warawut Khangkhan Chapter 4 Function 23
  • 24. global global F F external F F F F global F F F F F F F F F F F F F F Mr.Warawut Khangkhan Chapter 4 Function 24
  • 25. global (Cont.) F global F F global F F Mr.Warawut Khangkhan Chapter 4 Function 25
  • 26. local local F F automatic F F F local F F F F F F F F F F F F local F F F F F F F F F local F F Mr.Warawut Khangkhan Chapter 4 Function 26