SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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

Tendances (20)

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

Similaire à Function C

Session and Cookie
Session and CookieSession and Cookie
Session and CookieWarawut
 
Database Design
Database DesignDatabase Design
Database DesignWarawut
 
Ch01 introduction-web
Ch01 introduction-webCh01 introduction-web
Ch01 introduction-webWarawut
 
พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์
พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์
พื้นฐานภาษาสำหรับพัฒนาเว็บไซต์Warawut
 
การใช้เครื่องมือ (Tools) พื้นฐานในโปรแกรม Adobe Photoshop CS3 ที่มา http://...
การใช้เครื่องมือ (Tools)  พื้นฐานในโปรแกรม Adobe  Photoshop CS3 ที่มา http://...การใช้เครื่องมือ (Tools)  พื้นฐานในโปรแกรม Adobe  Photoshop CS3 ที่มา http://...
การใช้เครื่องมือ (Tools) พื้นฐานในโปรแกรม Adobe Photoshop CS3 ที่มา http://...เชาวลักษณ์ ชาวงษ์
 
Management Information System 4
Management Information System 4Management Information System 4
Management Information System 4Warawut
 
คู่มือโปรแกรม Book mark2551
คู่มือโปรแกรม Book mark2551  คู่มือโปรแกรม Book mark2551
คู่มือโปรแกรม Book mark2551 Narongchai Wanmanee
 
Object-Oriented Programming 7
Object-Oriented Programming 7Object-Oriented Programming 7
Object-Oriented Programming 7Warawut
 
Object-Oriented Programming 8
Object-Oriented Programming 8Object-Oriented Programming 8
Object-Oriented Programming 8Warawut
 
Display Table Demo
Display Table DemoDisplay Table Demo
Display Table DemoWarawut
 
Object-Oriented Programming 9
Object-Oriented Programming 9Object-Oriented Programming 9
Object-Oriented Programming 9Warawut
 
กลุ่ม3
กลุ่ม3กลุ่ม3
กลุ่ม3bannoi001
 

Similaire à Function C (20)

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

Plus de Warawut

Database design
Database designDatabase design
Database designWarawut
 
Object-Oriented Programming 10
Object-Oriented Programming 10Object-Oriented Programming 10
Object-Oriented Programming 10Warawut
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6Warawut
 
Management Information System 6
Management Information System 6Management Information System 6
Management Information System 6Warawut
 
Management Information System 5
Management Information System 5Management Information System 5
Management Information System 5Warawut
 
Object-Oriented Programming 5
Object-Oriented Programming 5Object-Oriented Programming 5
Object-Oriented Programming 5Warawut
 
Business Computer Project 3
Business Computer Project 3Business Computer Project 3
Business Computer Project 3Warawut
 
Management Information System 3
Management Information System 3Management Information System 3
Management Information System 3Warawut
 
Business Computer Project 2
Business Computer Project 2Business Computer Project 2
Business Computer Project 2Warawut
 
Chapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemChapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemWarawut
 
Object-Oriented Programming 4
Object-Oriented Programming 4Object-Oriented Programming 4
Object-Oriented Programming 4Warawut
 
Business Computer Project 1
Business Computer Project 1Business Computer Project 1
Business Computer Project 1Warawut
 
Chapter 1 Organization & MIS
Chapter 1 Organization & MISChapter 1 Organization & MIS
Chapter 1 Organization & MISWarawut
 
Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3Warawut
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2Warawut
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1Warawut
 
Upload File
Upload FileUpload File
Upload FileWarawut
 
Form Validation
Form ValidationForm Validation
Form ValidationWarawut
 
Tips & Track
Tips & TrackTips & Track
Tips & TrackWarawut
 
Edit & Delete Data
Edit & Delete DataEdit & Delete Data
Edit & Delete DataWarawut
 

Plus de Warawut (20)

Database design
Database designDatabase design
Database design
 
Object-Oriented Programming 10
Object-Oriented Programming 10Object-Oriented Programming 10
Object-Oriented Programming 10
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6
 
Management Information System 6
Management Information System 6Management Information System 6
Management Information System 6
 
Management Information System 5
Management Information System 5Management Information System 5
Management Information System 5
 
Object-Oriented Programming 5
Object-Oriented Programming 5Object-Oriented Programming 5
Object-Oriented Programming 5
 
Business Computer Project 3
Business Computer Project 3Business Computer Project 3
Business Computer Project 3
 
Management Information System 3
Management Information System 3Management Information System 3
Management Information System 3
 
Business Computer Project 2
Business Computer Project 2Business Computer Project 2
Business Computer Project 2
 
Chapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemChapter 2 Strategy & Information System
Chapter 2 Strategy & Information System
 
Object-Oriented Programming 4
Object-Oriented Programming 4Object-Oriented Programming 4
Object-Oriented Programming 4
 
Business Computer Project 1
Business Computer Project 1Business Computer Project 1
Business Computer Project 1
 
Chapter 1 Organization & MIS
Chapter 1 Organization & MISChapter 1 Organization & MIS
Chapter 1 Organization & MIS
 
Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
 
Upload File
Upload FileUpload File
Upload File
 
Form Validation
Form ValidationForm Validation
Form Validation
 
Tips & Track
Tips & TrackTips & Track
Tips & Track
 
Edit & Delete Data
Edit & Delete DataEdit & Delete Data
Edit & Delete Data
 

Dernier

Benifits of Individual And Team Sports-Group 7.pptx
Benifits of Individual And Team Sports-Group 7.pptxBenifits of Individual And Team Sports-Group 7.pptx
Benifits of Individual And Team Sports-Group 7.pptxsherrymieg19
 
PPT on INDIA VS PAKISTAN - A Sports Rivalry
PPT on INDIA VS PAKISTAN - A Sports RivalryPPT on INDIA VS PAKISTAN - A Sports Rivalry
PPT on INDIA VS PAKISTAN - A Sports Rivalryanirbannath184
 
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docx
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docxJORNADA 2 LIGA MUROBASQUETBOL1 2024.docx
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docxArturo Pacheco Alvarez
 
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...Eticketing.co
 
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptx
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptxPGC _ 3.1 _ Powerpoint (2024) scorm ready.pptx
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptxaleonardes
 
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docx
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docxItaly Vs Albania Euro Cup 2024 Italy's Strategy for Success.docx
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docxWorld Wide Tickets And Hospitality
 
Clash of Titans_ PSG vs Barcelona (1).pdf
Clash of Titans_ PSG vs Barcelona (1).pdfClash of Titans_ PSG vs Barcelona (1).pdf
Clash of Titans_ PSG vs Barcelona (1).pdfMuhammad Hashim
 
Project & Portfolio, Market Analysis: WWE
Project & Portfolio, Market Analysis: WWEProject & Portfolio, Market Analysis: WWE
Project & Portfolio, Market Analysis: WWEDeShawn Ellis
 
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024DONAL88 >LINK SLOT PG SOFT TERGACOR 2024
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024DONAL88 GACOR
 
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...World Wide Tickets And Hospitality
 
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptx
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptxBADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptx
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptxvillenoc6
 

Dernier (12)

Benifits of Individual And Team Sports-Group 7.pptx
Benifits of Individual And Team Sports-Group 7.pptxBenifits of Individual And Team Sports-Group 7.pptx
Benifits of Individual And Team Sports-Group 7.pptx
 
PPT on INDIA VS PAKISTAN - A Sports Rivalry
PPT on INDIA VS PAKISTAN - A Sports RivalryPPT on INDIA VS PAKISTAN - A Sports Rivalry
PPT on INDIA VS PAKISTAN - A Sports Rivalry
 
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docx
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docxJORNADA 2 LIGA MUROBASQUETBOL1 2024.docx
JORNADA 2 LIGA MUROBASQUETBOL1 2024.docx
 
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...
Turkey Vs Georgia Vincenzo Montella's Squad Selection for Turkey's Euro 2024 ...
 
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptx
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptxPGC _ 3.1 _ Powerpoint (2024) scorm ready.pptx
PGC _ 3.1 _ Powerpoint (2024) scorm ready.pptx
 
NATIONAL SPORTS DAY WRITTEN QUIZ by QUI9
NATIONAL SPORTS DAY WRITTEN QUIZ by QUI9NATIONAL SPORTS DAY WRITTEN QUIZ by QUI9
NATIONAL SPORTS DAY WRITTEN QUIZ by QUI9
 
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docx
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docxItaly Vs Albania Euro Cup 2024 Italy's Strategy for Success.docx
Italy Vs Albania Euro Cup 2024 Italy's Strategy for Success.docx
 
Clash of Titans_ PSG vs Barcelona (1).pdf
Clash of Titans_ PSG vs Barcelona (1).pdfClash of Titans_ PSG vs Barcelona (1).pdf
Clash of Titans_ PSG vs Barcelona (1).pdf
 
Project & Portfolio, Market Analysis: WWE
Project & Portfolio, Market Analysis: WWEProject & Portfolio, Market Analysis: WWE
Project & Portfolio, Market Analysis: WWE
 
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024DONAL88 >LINK SLOT PG SOFT TERGACOR 2024
DONAL88 >LINK SLOT PG SOFT TERGACOR 2024
 
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...
Spain Vs Italy Showdown Between Italy and Spain Could Determine UEFA Euro 202...
 
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptx
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptxBADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptx
BADMINTON EQUIPMENTS / EQUIPMENTS GROUP9.pptx
 

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