SlideShare una empresa de Scribd logo
1 de 45
6/1
(Function)
type                                             int ,
float , char , double , void
                                             void
                                      int
   function_name

   type parameter                    parameter
      ,     N
                         parameter          void
   {
   location variable declaration

   statement_ ; statement_ ; ... statement_N
   return(value);
F N T N INC
                         U C IO S


             CS A D R
               TNAD                  PO RM E
                                     R G A MR
             LIBRARY            DF E F N T N
                                 E IN D U C IO


1.                                               User-defined
     Function)

2.                      Standard Function)

           include directives             header file
1.




1.1
type function_name(type1 arg1, type2 arg2,.., typeN argN)
  {
  local variable declaration;
  statement(s);
  return( varlue);
  }
type
                        type             int, float, char
double                                  int
                                            type      void
function_name
type1 arg1, type2 arg2,…, typeN argN
                             argument       1, 2, 3,…, N
         void
{
}
local variable declaration
                local
statement(s)                                               1
                                        ; (semicolon)
return(value)
           value             ()
#include<stdio.h>
#include<conio.h>
void one(void); /* function Prototype
void two(void); /* function Prototype
void main(void)
{
clrscr();
one(); /* call one() */
two(); /* call two() */
printf("nPress any key back to program ...");
getch();
}
/* one function */
void one()
{
int a=5, b=7;
printf("A = %d, B = %dn",a,b);
}
/* two function */
void two()
{
float p=4.5, q=3.5;
p+=q;
printf("P = %6.3f, Q = %6.3fn",p,q);
}
3         4       void one(void);         void two(void);

                        one( )        two( )
                                         void                           one( )
two( )                                                               void
         ()                      one( )       two                       argument


         main( )

              8         9          one( );      two( );
     one( )            two( )                             one( )
    14   18                       two( )                  20    25
            14          18           one( )                                a
b
              20        25            two( )                                p




    
    
    
1.2
          2




#include <stdio.h>   #include <stdio.h>
Main ()              Main ()
{                    {
Function-name2 ();         Function-name1 ();
…………………...                 Function-name2
Function-name1 ();   ();
}                          …………………..
                     }


    #include
1.3



                                  ()

      void function_name(void )
#include<stdio.h>
#include<conio.h>
void asterisk_line(void);
void main(void)
{
clrscr( );
asterisk_line( );
printf("****** C and C++ PROGRAMMING ******n");
asterisk_line();
printf("nPress any key back to program ...");
getch();
}
/* asterisk_line function */
void asterisk_line( )
{
int j, n=40;
for(j=1; j<=n; j++)
printf("*");
printf("n");
}
3      void asterisk_line (void);
    asterisk_line( )

    7    9                             asterisk_line(
)                     14    19
    14   19         asterisk_line( )
    *      40
    10    11
                                enter
1.4




      void function_name (type_parameter parameter_name [,..] ) ;
#include <stdio.h>
Void addition (int , int ) ;
Void main ()
{
Int a,b ;
……....
Addition (a,b) ;
}
Void addition (int m , int n)
{
…............
}
1.5




        Type_variable function_name
  (parameter_name

 Type_variable

  function_name
  parameter_name



    #include<stdio.h>
    #include<conio.h>
    int calculate(int, int);
    void main(void)
    {
    int p=3, q=4, r;
    clrscr( );
    r = calculate(p,q);
    printf("P = %d, Q = %d, R = %dn",p,q,r);
    printf("nPress any key back to program ...");
    getch();
    } /* end main() */
    int calculate(int p, int q)
    {
    return (p+q);
    }
3     int calculate (int, int);
                               argument       2       int
                                              int
             caculate( )
            8       r = caculate (p, q);
          caculate( )            p      q
                              caculate( )
13   16
            13      16        caculate( )
                    p     q
                                            main( )
                    r
            9                 p, q      r
1.6

                      variable_name = function_name();
      variable_name


                             return (value)


1.7




         (Local Variable)


          (Global Variable)

      (
                       )

/* 7th Sample Program: Local vs Global Variable */
#include<stdio.h>
int ans = 0;
 int inc_one(int);                 /* function prototype */
void main()
{
   int a = 3;
   ans = inc_one(a);
   printf(“Answer is %dn”, ans);
}
/* function definition: return x+1 */
int inc_one(int x)
{
   int ans;
   ans = x + 1;
   return ans;
}
ans

       (main)
            ans

                             a

        inc_one         x     ans
                  ans
            ans

                            inc_one
      ans
inc_one                           ans

    PROGRAM AA;
    VAR NUM:INTEGER;
    PROCEDURE A;
    BEGIN
    NUM:=NUM*10;                     RUN
    WRITELN(‘NUM*10 = ‘,NUM);
    END;                             NUM*10 = 50
    VAR ANY:INTEGER;
    PROCEDURE B;                     NUM = 124
    VAR NUM,CNTR:INTEGER;
    BEGIN
                                     CNTR = 122
    NUM:=124;                        BACK TO MAIN
    WRITELN(‘NUM = ‘,NUM);
    CNTR:=122;                       NUM = 50
    WRITELN(‘CNTR =’,CNTR);
    END;
    BEGIN {MAIN PROGRAM}
    NUM:=5;
    WRITELN(‘IN MAIN’,’NUM = ‘,NUM);
    A;
    B;
    WRITELN(‘BACK TO MAIN NUM = ‘,NUM);
    END.
- NUM
output                                 output       program
    A
- NUM, cntr                 program       B            B

       NUM        NUM
    NUM                        NUM=5            A
    10   50        B                124
                  124            50             NUM

-     procedure B                      ANY
        procedure A                   procedure B

-             B         A      A         B
2.

                C




                Header
     #include
#include<stdio.h> #include<math.h>
void main()                            Square root 4 =
                                       Square root 4 =
{                                    2.000000
                                      2.000000
  printf(“square root 4 =”);         5 power 3 =
                                      5 power 3 =
  printf(“%fn”, sqrt(4));
                                     125.000000
                                      125.000000
  printf(“5 power 3 =”);
  printf(“%f”, pow(5,3));
}


              include               .h
                   printf      scanf       include
  stdio.h
                                         sqrt    pow
  include        math.h
2.1

               math.h
                 double
          double
                          sin(), cos()
  tan()
math.h
                 double
    double
     sin(x)                                            sine       x

      cos(x)        cosine         x                          (radian)
      tan(x)        tangent            x
(radian)
      sqrt(x)                          x           x

     exp(x)         ex        e                        2.718282
      pow(x,y)         xy
     log(x)         log       e            natural logarithm
    x
     log10(x)         log         10       x

     ceil(x)                                   x         x
2.2
(string.h)•            string.h


         strcpy
                 :                        string 2
            string 1
          < strcpy (          ,             )
           >
                              strcpy string 1,string 2


         strcat
                  :
  string 2                       string 1
                             strcat string 1,string 2
strcmp
       :
   string 1              string 2             1

   string 1   string 2         0
                   strcmp string 1,string 2
strlen
         :
                       strlen string
strcmpi
       :
   string 1                string 2               0

   string 1            < string 2           <0
   string 1            > string 2           >0
                  strcmpi string 1,string 2
2.3
                            #include <ctype.h>
      TOLOWER            LOWER




              TOLOWER(text)


       text

      TOUPPER           UPPER                    LOWER
       TOUPPER


              TOUPPER(text)
2

         4
1.
2.
3.   -
4.
–




printf
1.          char s3[5] = {‘G’, ‘O’, ‘O’, ‘D’, ‘0’};   s3

     ก)
     ข)
     ค)              .          .
     ง)
2.
     ก)
     ข)
     ค)                          .
     ง)
3.

     ก)   int function_name(type arg, …)
     ข)   void function_name(type arg, …)
     ค)   function_name(type arg, ….)
     ง)   void function_name()
4.
     ก)
     ข)
     ค)
     ง)
5.

     ก)
     ข)    
     ค)   {} []
     ง)
6.            char s1[9] = “LANGUAGE”;   s1

     ก)
     ข)
     ค)            .        .
     ง)
7.           char s2[4] = {‘G’, ‘O’, ‘O’, ‘D’};   s2

     ก)
     ข)
     ค)              .          .
     ง)
8.
     ก)   function_name();
     ข)   function_name()
     ค)   function_name(arg1,arg2)
     ง)    Function_name(arg1; arg2);
9.

     ก) int function_name(type arg, …)
     ข) void function_name(type arg, …)
     ค) function_name(type arg, ….)
     ง)   void function_name()
10.

  ก)   strcmp    strcmp string 1,string 2
  ข)   strcat   strcat string 1,string 2
  ค)   strcpy    strcpy string 1,string 2
  ง)   strlen   strlen string
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
1.         13
2.          14
3.         19
4.          21
5.         22
6.          23

     6/1

Más contenido relacionado

La actualidad más candente

Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019corehard_by
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumpingMomenMostafa
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string libraryMomenMostafa
 

La actualidad más candente (20)

Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
Function in c program
Function in c programFunction in c program
Function in c program
 
functions
functionsfunctions
functions
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
Functions
FunctionsFunctions
Functions
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
Function lecture
Function lectureFunction lecture
Function lecture
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
Function in c
Function in cFunction in c
Function in c
 

Destacado

Destacado (11)

Post meeting som092010
Post meeting som092010Post meeting som092010
Post meeting som092010
 
Korea club tour2010
Korea club tour2010Korea club tour2010
Korea club tour2010
 
Leon thai sup
Leon thai supLeon thai sup
Leon thai sup
 
Slide 60 mm radio_october_mc and o b
Slide 60 mm radio_october_mc and o bSlide 60 mm radio_october_mc and o b
Slide 60 mm radio_october_mc and o b
 
David solomon lecture
David solomon lectureDavid solomon lecture
David solomon lecture
 
Slimclub
SlimclubSlimclub
Slimclub
 
Radio retail 10112010 อุ๋ย
Radio retail 10112010 อุ๋ยRadio retail 10112010 อุ๋ย
Radio retail 10112010 อุ๋ย
 
Bbbbbbbbbbbbbbb
BbbbbbbbbbbbbbbBbbbbbbbbbbbbbb
Bbbbbbbbbbbbbbb
 
Sup2 wt#part2
Sup2 wt#part2Sup2 wt#part2
Sup2 wt#part2
 
Dcs operator training
Dcs operator trainingDcs operator training
Dcs operator training
 
อาหารบำบัดโรคไต
อาหารบำบัดโรคไตอาหารบำบัดโรคไต
อาหารบำบัดโรคไต
 

Similar a ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1

Similar a ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1 (20)

Unit2 jwfiles
Unit2 jwfilesUnit2 jwfiles
Unit2 jwfiles
 
Function recap
Function recapFunction recap
Function recap
 
Function recap
Function recapFunction recap
Function recap
 
C-Language Unit-2
C-Language Unit-2C-Language Unit-2
C-Language Unit-2
 
Functions
FunctionsFunctions
Functions
 
Functions
FunctionsFunctions
Functions
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
Functions
FunctionsFunctions
Functions
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Lab Question
Lab QuestionLab Question
Lab Question
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Function in C program
Function in C programFunction in C program
Function in C program
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
Cquestions
Cquestions Cquestions
Cquestions
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 

Más de Little Tukta Lita

งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1Little Tukta Lita
 
บทที่ 5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1
บทที่  5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1บทที่  5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1
บทที่ 5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1Little Tukta Lita
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบLittle Tukta Lita
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบLittle Tukta Lita
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบLittle Tukta Lita
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1Little Tukta Lita
 

Más de Little Tukta Lita (8)

งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
มายแม็บ
มายแม็บมายแม็บ
มายแม็บ
 
บทที่ 5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1
บทที่  5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1บทที่  5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1
บทที่ 5 ข้อมูลชนิดอาร์เรย์และสตริง 6.1
 
It news
It newsIt news
It news
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบ
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบ
 
สรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบสรุปงานผู้ทดสอบ
สรุปงานผู้ทดสอบ
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม.6.1
 

Último

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1

  • 1. 6/1
  • 3.
  • 4. type int , float , char , double , void void int function_name type parameter parameter , N parameter void { location variable declaration statement_ ; statement_ ; ... statement_N return(value);
  • 5. F N T N INC U C IO S CS A D R TNAD PO RM E R G A MR LIBRARY DF E F N T N E IN D U C IO 1. User-defined Function) 2. Standard Function) include directives header file
  • 6. 1. 1.1 type function_name(type1 arg1, type2 arg2,.., typeN argN) { local variable declaration; statement(s); return( varlue); }
  • 7. type type int, float, char double int type void function_name type1 arg1, type2 arg2,…, typeN argN argument 1, 2, 3,…, N void { } local variable declaration local statement(s) 1 ; (semicolon) return(value) value ()
  • 8. #include<stdio.h> #include<conio.h> void one(void); /* function Prototype void two(void); /* function Prototype void main(void) { clrscr(); one(); /* call one() */ two(); /* call two() */ printf("nPress any key back to program ..."); getch(); } /* one function */ void one() { int a=5, b=7; printf("A = %d, B = %dn",a,b); } /* two function */ void two() { float p=4.5, q=3.5; p+=q; printf("P = %6.3f, Q = %6.3fn",p,q); }
  • 9. 3 4 void one(void); void two(void); one( ) two( ) void one( ) two( ) void () one( ) two argument main( ) 8 9 one( ); two( ); one( ) two( ) one( ) 14 18 two( ) 20 25 14 18 one( ) a b 20 25 two( ) p
  • 10.       
  • 11. 1.2 2   #include <stdio.h> #include <stdio.h> Main () Main () { { Function-name2 (); Function-name1 (); …………………... Function-name2 Function-name1 (); (); } ………………….. }
  • 12. #include
  • 13. 1.3 () void function_name(void )
  • 14. #include<stdio.h> #include<conio.h> void asterisk_line(void); void main(void) { clrscr( ); asterisk_line( ); printf("****** C and C++ PROGRAMMING ******n"); asterisk_line(); printf("nPress any key back to program ..."); getch(); } /* asterisk_line function */ void asterisk_line( ) { int j, n=40; for(j=1; j<=n; j++) printf("*"); printf("n"); }
  • 15. 3 void asterisk_line (void); asterisk_line( ) 7 9 asterisk_line( ) 14 19 14 19 asterisk_line( ) * 40 10 11 enter
  • 16. 1.4 void function_name (type_parameter parameter_name [,..] ) ;
  • 17. #include <stdio.h> Void addition (int , int ) ; Void main () { Int a,b ; …….... Addition (a,b) ; } Void addition (int m , int n) { …............ }
  • 18. 1.5 Type_variable function_name (parameter_name Type_variable function_name parameter_name
  • 19.
  • 20. #include<stdio.h> #include<conio.h> int calculate(int, int); void main(void) { int p=3, q=4, r; clrscr( ); r = calculate(p,q); printf("P = %d, Q = %d, R = %dn",p,q,r); printf("nPress any key back to program ..."); getch(); } /* end main() */ int calculate(int p, int q) { return (p+q); }
  • 21. 3 int calculate (int, int); argument 2 int int caculate( ) 8 r = caculate (p, q); caculate( ) p q caculate( ) 13 16 13 16 caculate( ) p q main( ) r 9 p, q r
  • 22. 1.6 variable_name = function_name(); variable_name return (value) 
  • 23.
  • 24. 1.7  (Local Variable)  (Global Variable) ( )
  • 25.  /* 7th Sample Program: Local vs Global Variable */ #include<stdio.h> int ans = 0; int inc_one(int); /* function prototype */ void main() { int a = 3; ans = inc_one(a); printf(“Answer is %dn”, ans); } /* function definition: return x+1 */ int inc_one(int x) { int ans; ans = x + 1; return ans; }
  • 26. ans (main) ans a inc_one x ans ans ans inc_one ans inc_one ans
  • 27. PROGRAM AA; VAR NUM:INTEGER; PROCEDURE A; BEGIN NUM:=NUM*10; RUN WRITELN(‘NUM*10 = ‘,NUM); END; NUM*10 = 50 VAR ANY:INTEGER; PROCEDURE B; NUM = 124 VAR NUM,CNTR:INTEGER; BEGIN CNTR = 122 NUM:=124; BACK TO MAIN WRITELN(‘NUM = ‘,NUM); CNTR:=122; NUM = 50 WRITELN(‘CNTR =’,CNTR); END; BEGIN {MAIN PROGRAM} NUM:=5; WRITELN(‘IN MAIN’,’NUM = ‘,NUM); A; B; WRITELN(‘BACK TO MAIN NUM = ‘,NUM); END.
  • 28. - NUM output output program A - NUM, cntr program B B NUM NUM NUM NUM=5 A 10 50 B 124 124 50 NUM - procedure B ANY procedure A procedure B - B A A B
  • 29. 2. C Header #include
  • 30. #include<stdio.h> #include<math.h> void main() Square root 4 = Square root 4 = { 2.000000 2.000000 printf(“square root 4 =”); 5 power 3 = 5 power 3 = printf(“%fn”, sqrt(4)); 125.000000 125.000000 printf(“5 power 3 =”); printf(“%f”, pow(5,3)); } include .h printf scanf include stdio.h sqrt pow include math.h
  • 31. 2.1 math.h double double sin(), cos() tan()
  • 32. math.h double double sin(x) sine x cos(x) cosine x (radian) tan(x) tangent x (radian) sqrt(x) x x exp(x) ex e 2.718282 pow(x,y) xy log(x) log e natural logarithm x log10(x) log 10 x ceil(x) x x
  • 33.
  • 34. 2.2 (string.h)• string.h strcpy : string 2 string 1 < strcpy ( , ) > strcpy string 1,string 2 strcat : string 2 string 1 strcat string 1,string 2
  • 35. strcmp : string 1 string 2 1 string 1 string 2 0 strcmp string 1,string 2 strlen : strlen string strcmpi : string 1 string 2 0 string 1 < string 2 <0 string 1 > string 2 >0 strcmpi string 1,string 2
  • 36. 2.3 #include <ctype.h> TOLOWER LOWER TOLOWER(text) text TOUPPER UPPER LOWER TOUPPER TOUPPER(text)
  • 37.
  • 38. 2 4 1. 2. 3. - 4.
  • 40. 1. char s3[5] = {‘G’, ‘O’, ‘O’, ‘D’, ‘0’}; s3 ก) ข) ค) . . ง) 2. ก) ข) ค) . ง) 3. ก) int function_name(type arg, …) ข) void function_name(type arg, …) ค) function_name(type arg, ….) ง) void function_name()
  • 41. 4. ก) ข) ค) ง) 5. ก) ข)  ค) {} [] ง) 6. char s1[9] = “LANGUAGE”; s1 ก) ข) ค) . . ง)
  • 42. 7. char s2[4] = {‘G’, ‘O’, ‘O’, ‘D’}; s2 ก) ข) ค) . . ง) 8. ก) function_name(); ข) function_name() ค) function_name(arg1,arg2) ง) Function_name(arg1; arg2); 9. ก) int function_name(type arg, …) ข) void function_name(type arg, …) ค) function_name(type arg, ….) ง) void function_name()
  • 43. 10. ก) strcmp strcmp string 1,string 2 ข) strcat strcat string 1,string 2 ค) strcpy strcpy string 1,string 2 ง) strlen strlen string
  • 45. 1. 13 2. 14 3. 19 4. 21 5. 22 6. 23 6/1