SlideShare a Scribd company logo
F   F
F
                      F
    F
              F F         F
        Interactive


                              2
F
          Preprocessor
           Directives

        Global Declarations

    void main(void) {
         Local Declarations

            Statements
    }


                              3
Preprocessor Directives
              F
            file                     F   F

    F                (Header File)
        F          Directive #


                                             4
Preprocessor Directives
             Directive                            F
     #include            Include text from file
     #define             Define a macro
     #undef              Undefine a macro
     #if                 Test if a compile-time condition hold
     #ifdef              Test if a symbol is defined
     #ifndef             Test if a symbol is not defined
     #else               Indicate alternatives if a test fails
     #elif               Combination of #if and #else
     #endif              End a preprocessor conditional
     #line               Give a line number for compiler message
     #error              Terminate processing early
     #pragma             Implementation dependent directive

                                                                   5
#include
           F   F Compiler F       F     F    Compile
  F
           #include FILE NAME
       F
 #include stdio.h        F       F stdio.h
 #include conio.h            F   F conio.h
                                                       6
#define
                   F   F F

            #define NAME VALUE
        F
#define PI 3.14              F       PI F   3.14
#define X 3.14*2                 F   X F    3.14*2
                                                     7
Global Declarations
          F           F
      F           F               F
                          F               F F
              F               F       F



                                                8
Main () function F                        F
                      F

   main()
     F         F          F       ;
       F F   main()           F       {       F   }


                                                      9
F                     (Program Comment)
    F        F

        //       comment 1
        /*       comment 1      */
        /*       comment       F 1
                             .*/

                                          10
F
                      F
    F
              F F         F
        Interactive


                              11
#include stdio.h
void main() {
                   .;
                   .;
}

                        12
#include stdio.h
void main() {
  printf( Hello World );
  // F F Hello World
}                        Hello World


                                        13
#include stdio.h
void main() {
  printf( Hellon );
  printf( World );
}                      Hello
                       World

                                14
#include stdio.h
void main() {
  printf( Hellon );
  printf( Worldn );
}                      Hello
                       World
                       

                               15
F
                      F
    F
              F F         F
        Interactive


                              16
#include stdio.h                    PI
                                   3.14
#define PI 3.14                 r      area
void main() {                20.00      0.0

   float r = 20.00, circum = 0.0;      125.6

 circum = 2 * PI * r;
   printf( Circumference is %f Radius is
    %fn , circum,r); }
                                               17
F
                      F
    F
              F F         F
        Interactive


                              18
F F
keyboard
                 scanf(...)



monitor

                 printf(...)
                               Memory

                                        19
F F   F
  F         F
printf()
putchar()
puts()




                          20
F F   F
  F         F   F
scanf()
getchar()
getch()
getche()
gets()

                              21
F F   F
  F         F
printf()
putchar()
puts()




                          22
F       printf
           F             F F      F

       F       #include stdio.h


printf(“Control String”,arg1,arg2,arg3,..);
printf(“Control String”);

                                              23
printf(“%dn%d”,a,b);


         %dn%d           a,b


Memory     a    22   b   30


                                22
  22 -> 30 .                    30

Output Stream

                                     24
F        printf :             F
    printf( Computer Programming 1 );
    printf( ComputernProgramming 1 );
    printf( Result is %f ,area);
    printf( Result isn%f ,area);

                                         25
F         printf :                      F
                   F      10 + 3       F

  START                        X
                       (1.         F 10 + 3           X)
                       1. X = 10 +3
X = 10 + 3             (2.       F X              )
                       2. PRINT          10 + 3
                          PRINT X
 PRINT X



       END


                                                           26
F        printf :
                                                F
n                              F
t            F       6
r       cursor           F F
f            F                     1   F
b       cursor                     1       F       F
a        F
                 F
                 F

                                                        27
F   printf :                                     F
                                                   F
%d           F   F
%ld          F   F                      long int
%u           F   F                        F
%f           F   F                  float
%lf          F   F                  double
%Lf          F   F                  long double
%e           F   F
%c           F   F                 (char)
%s           F   F           (string)     F
%%           F   F           %
%o           F   F
%x           F   F
%p           F   F address     pointer
                                                           28
F     printf :            F
int j=45, k = -123;      printf(“Hellon”);
float x = 12.34          printf(“Tax is 10%%n”);
char c = ‘A’;            printf(“%dn”,j);
char *m = “Hello”;
char mm[6] = “Hello” ;
                         printf(“%dn”,k);
                         printf(“%fn”,x);
                         printf(“%6.2fn”,x);
                         printf(“%cn”,c);
                         printf(“%dn”,c);

                                                    29
F      printf :           F
int j=45, k = -123;
                         printf(“%dn”,c+1);
float x = 12.34          printf(“%cn”,c+1);
char c = ‘A’;            printf(“%sn”,m);
char *m = “Hello”;       printf(“%sn”,mm);
char mm[6] = “Hello” ;
                         printf(“%en”,x);
                         printf(“%En”,x);



                                               30
F   printf :   F




                   31
F             printf :         F
    F                     %d        %4d
         12          12              12
        123          123            123
    1234             1234          1234
12345                12345         12345

                                           32
#include stdio.h     #include stdio.h
void main() {        void main() {
  printf( Yesn );     printf( Yesn );
  printf( Non );      printf( n );
}                      printf( Non );
                     }

                                          33
#include stdio.h   #include stdio.h
void main() {      void main() {
  printf( Yes );     printf( YesnNo );
  printf( No );    }
}


                                      34
#include < stdio.h >
void main ( ) {
   //                        number          F
   int number;
   //         F 8 F           number
   number = 8;
   printf ( The value of number is %d . , number);
}


        The value of number is 8 .

                                                     35
#include stdio.h Circumference is 125.6
                      
#define PI 3.14
void main() {
  float r = 20.00, circum = 0.0;
  circum = 2 * PI * r;
  printf( Circumference is %.1fn , circum);
   }
                                          36
#include stdio.h
#define PI 3.14
void main ( ) {
   float r, area;
   printf ( This program computes the area of a circlen );
   r = 12.5;          /*          F        F       12.5 */
   area = PI * r * r; /*                 = ¶ r2 */
   printf ( Area = Pi x radius x radiusn );
   printf (      = %.2f x %.2f x %.2fn , PI, r, r);
   printf (      = %fn , area);
            This program computes the area of a circle
            Area = Pi x radius x radius
                = 3.14 x 12.50 x 12.50
                = 490.873444
            
                                                              37
#include < stdio.h >
#define SIXTY              60 /*       SIXTY F        F               F */
void main ( ) {
   float hour; //            hour               F         F
   int minute, second; //           2                             F
   hour = 1.5; //         F 1.5 F             hour
   //     F             hour F 60 F                 F       F          minute
   minute = hour * SIXTY;
   //       F           minute F 60 F                   F     F              second
   second = minute * SIXTY;
   printf ( In one period : n %.2f hoursn , hour);
   printf ( %d minutesn%d seconds , minute, second);
}                      In one period :
                       1.50 hours
                       90 minutes
                       5400 seconds                                                  38
F F   F
  F         F
printf()
putchar()
puts()




                          39
F         putchar
          F                      1

    F         #include stdio.h


        putchar(variable);




                                     40
F    putchar :        F
#include “stdio.h”
void main ( ) {
  char s;
  s = ‘A’;
  putchar(s);
}

                     A

                             41
F F   F
  F         F
printf()
putchar()
puts()




                          42
F           puts
             F
     F   F                     F
                 F 1
variable               F   F            F
 F                                 F1

         puts(variable);


                                            43
F     puts :             F
#include “stdio.h”
#include<string.h>
void main ( ) {
  char str[30];
  str = “C Programming”;
  strcpy(str,”C programming”);
  puts(str);
  printf(“nOutput = %sn”,str);
}
            C Programming
            Output = C Programming
            
                                     44
F F   F
  F       F         F
scanf()
getchar()
getch(), getche()
gets()


                                  45
F       scanf
           F            F   F              F   F

                  Enter F              F
               F    F              F
       F         include stdio.h

scanf(“Control String”,&arg1,&arg2,&arg3,..);

                                                   46
scanf(“%d%f”,&a,&b);


    %d%f           a,b



     22 30 .             a   22   b   30
   Input Stream
                  int a;
                  float b;
                  scanf( %d%f ,&a,&b);
                                           47
F    Scanf :              F
int num;
scanf( %d ,&num);
printf( the value in num variable is %d ,num);
char str[80];
printf( Enter a string : );
scanf( %s ,str);
printf( Here s your string : %s , str);
                                                 48
#include < stdio.h >
void main ( ) {
   int years;
   printf ( How long have you been here? );
   scanf ( %d , &years);
   printf ( You ve been here for %d years. , years);
   printf ( tReally? );
}



     How long have you been here? 20
     You’ve been here for 20 years.                Really?


                                                              49
F F   F
  F       F         F
scanf()
getchar()
getch() ,getche()
gets()


                                  50
F       getchar
        F       F                       F               F
                        1   F

                                            F
            1                   Enter
    F                                           F   F
                    F

            ch = getchar();

                                                            51
F     getchar :              F
#include “stdio.h”
void main ( ) {
  char ch;
  ch = getchar();
  printf(“The Character you typed is %cn”, ch);
}


            d
            The Character you typed is d
                                                   52
F F   F
  F       F        F
scanf()
getchar()
getch(),getche()
gets()


                                 53
F     getch(),getche()
           F                F       1            F
               F                F        F F         Enter

                   ch = getch();
           F                F       1
                    F                F         F F     Enter

                   ch = getche();
F       #include<conio.h>
                                                               54
F     getch :             F
#include “stdio.h”
#include “conio.h”
void main ( ) {
  char ch;
  ch = getch();
  printf(“The Character you typed is %cn”, ch);
}


            The Character you typed is d
                                                   55
F F   F
  F         F   F
scanf()
getchar()
getch()
gets()


                              56
F       gets
            F              F          F           F
                       F
                                              F
F                      Enter F
        F               F F       F       F           F
                F

                gets(variable);


                                                          57
F     gets :            F
#include “stdio.h”
void main ( ) {
  char str[51];
  gets(str);
  printf(“The Message you typed is %sn”, str);
}


            test
            The Message you typed is test
                                                  58
F
                      F
    F
              F F         F
        Interactive


                              59
Interactive
                            F
    F F                 F           F
F
                 F              F       F
          F
                                                F F F F

                                            F
              F F F F
                   F


                                                          60

More Related Content

What's hot

ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Elseใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
Nattapon
 
Index with Word 2007
Index with Word 2007Index with Word 2007
Index with Word 2007
Boonlert Aroonpiboon
 
1 โลกและการเปลี่ยนแปลง
1 โลกและการเปลี่ยนแปลง1 โลกและการเปลี่ยนแปลง
1 โลกและการเปลี่ยนแปลง
muang82
 
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
สร้างสรรค์ผลงานด้วยโปรแกรม  Adobe  Photoshop CS3 ที่มา http://www.skr.ac.th/~...สร้างสรรค์ผลงานด้วยโปรแกรม  Adobe  Photoshop CS3 ที่มา http://www.skr.ac.th/~...
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
เชาวลักษณ์ ชาวงษ์
 
ธรรมชาติของสิ่งมีชีวิต
ธรรมชาติของสิ่งมีชีวิตธรรมชาติของสิ่งมีชีวิต
ธรรมชาติของสิ่งมีชีวิต
Thanyamon Chat.
 
ระบบหมุนเวียน
ระบบหมุนเวียนระบบหมุนเวียน
ระบบหมุนเวียน
Thanyamon Chat.
 
ระบบน้ำเหลืองกับภูมิคุ้มกัน
ระบบน้ำเหลืองกับภูมิคุ้มกันระบบน้ำเหลืองกับภูมิคุ้มกัน
ระบบน้ำเหลืองกับภูมิคุ้มกัน
Thanyamon Chat.
 
การขับถ่ายของสัตว์
การขับถ่ายของสัตว์การขับถ่ายของสัตว์
การขับถ่ายของสัตว์
Thanyamon Chat.
 
Business Computer Project 4
Business Computer Project 4Business Computer Project 4
Business Computer Project 4
Warawut
 
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
Nattapon
 
07การเคลื่อนที่แบบหมุน
07การเคลื่อนที่แบบหมุน07การเคลื่อนที่แบบหมุน
07การเคลื่อนที่แบบหมุน
Doc Edu
 
01 form-mdi
 01 form-mdi 01 form-mdi
01 form-mdi
Warawut
 
นิเวศวิทยา(Hand out)
นิเวศวิทยา(Hand out)นิเวศวิทยา(Hand out)
นิเวศวิทยา(Hand out)
Thanyamon Chat.
 
20ฟิสิกส์นิวเคลียร์
20ฟิสิกส์นิวเคลียร์20ฟิสิกส์นิวเคลียร์
20ฟิสิกส์นิวเคลียร์
Doc Edu
 
08สภาพสมดุล
08สภาพสมดุล08สภาพสมดุล
08สภาพสมดุล
Doc Edu
 
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
Thanyamon Chat.
 
2553 13-performance
2553 13-performance2553 13-performance
2553 13-performance
ps-most
 

What's hot (17)

ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Elseใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
ใบความรู้ที่ 6-5 ฟังก์ชัน If, If-Else
 
Index with Word 2007
Index with Word 2007Index with Word 2007
Index with Word 2007
 
1 โลกและการเปลี่ยนแปลง
1 โลกและการเปลี่ยนแปลง1 โลกและการเปลี่ยนแปลง
1 โลกและการเปลี่ยนแปลง
 
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
สร้างสรรค์ผลงานด้วยโปรแกรม  Adobe  Photoshop CS3 ที่มา http://www.skr.ac.th/~...สร้างสรรค์ผลงานด้วยโปรแกรม  Adobe  Photoshop CS3 ที่มา http://www.skr.ac.th/~...
สร้างสรรค์ผลงานด้วยโปรแกรม Adobe Photoshop CS3 ที่มา http://www.skr.ac.th/~...
 
ธรรมชาติของสิ่งมีชีวิต
ธรรมชาติของสิ่งมีชีวิตธรรมชาติของสิ่งมีชีวิต
ธรรมชาติของสิ่งมีชีวิต
 
ระบบหมุนเวียน
ระบบหมุนเวียนระบบหมุนเวียน
ระบบหมุนเวียน
 
ระบบน้ำเหลืองกับภูมิคุ้มกัน
ระบบน้ำเหลืองกับภูมิคุ้มกันระบบน้ำเหลืองกับภูมิคุ้มกัน
ระบบน้ำเหลืองกับภูมิคุ้มกัน
 
การขับถ่ายของสัตว์
การขับถ่ายของสัตว์การขับถ่ายของสัตว์
การขับถ่ายของสัตว์
 
Business Computer Project 4
Business Computer Project 4Business Computer Project 4
Business Computer Project 4
 
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
บทที่ 6 1 ฟังก์ชัน printf scanf [slide]
 
07การเคลื่อนที่แบบหมุน
07การเคลื่อนที่แบบหมุน07การเคลื่อนที่แบบหมุน
07การเคลื่อนที่แบบหมุน
 
01 form-mdi
 01 form-mdi 01 form-mdi
01 form-mdi
 
นิเวศวิทยา(Hand out)
นิเวศวิทยา(Hand out)นิเวศวิทยา(Hand out)
นิเวศวิทยา(Hand out)
 
20ฟิสิกส์นิวเคลียร์
20ฟิสิกส์นิวเคลียร์20ฟิสิกส์นิวเคลียร์
20ฟิสิกส์นิวเคลียร์
 
08สภาพสมดุล
08สภาพสมดุล08สภาพสมดุล
08สภาพสมดุล
 
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
ระบบหายใจกับการรักษาดุลยภาพของร่างกาย(มนุษย์)
 
2553 13-performance
2553 13-performance2553 13-performance
2553 13-performance
 

Similar to โครงสร้างภาษาซี1

ใบความรู้เรื่องคำสั่ง Printf scanf
ใบความรู้เรื่องคำสั่ง Printf scanfใบความรู้เรื่องคำสั่ง Printf scanf
ใบความรู้เรื่องคำสั่ง Printf scanf
ธงชัย พาศรี
 
เขียนโปรแกรมใช้คำสั่ง Printf scanf
เขียนโปรแกรมใช้คำสั่ง  Printf scanfเขียนโปรแกรมใช้คำสั่ง  Printf scanf
เขียนโปรแกรมใช้คำสั่ง Printf scanf
ธงชัย พาศรี
 
C Language Program
C Language ProgramC Language Program
C Language Program
Warawut
 
9789740333036
97897403330369789740333036
9789740333036
CUPress
 
9789740333036
97897403330369789740333036
9789740333036
CUPress
 
การใช้งานโปรแกรม R เบื้องต้น
การใช้งานโปรแกรม R เบื้องต้นการใช้งานโปรแกรม R เบื้องต้น
การใช้งานโปรแกรม R เบื้องต้น
Kanda Runapongsa Saikaew
 
ชนิดข้อมูลและตัวแปร
ชนิดข้อมูลและตัวแปรชนิดข้อมูลและตัวแปร
ชนิดข้อมูลและตัวแปร
สุวิทย์ ดวงดี
 
SearchDemo
 SearchDemo SearchDemo
SearchDemo
Warawut
 
Java Web Service
Java Web ServiceJava Web Service
Java Web Service
vongthow
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
Little Tukta Lita
 
พื้นฐานการออกแบบโปรแกรม
พื้นฐานการออกแบบโปรแกรมพื้นฐานการออกแบบโปรแกรม
พื้นฐานการออกแบบโปรแกรม
Warawut
 
หนังสือ Cloning freebsd
หนังสือ Cloning freebsdหนังสือ Cloning freebsd
หนังสือ Cloning freebsd
Man Kb
 
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
Fraction.h #include iostream #ifndef FRACTION #define FR.pdfFraction.h #include iostream #ifndef FRACTION #define FR.pdf
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
ravikapoorindia
 
DataReaderDemo
DataReaderDemoDataReaderDemo
DataReaderDemo
Warawut
 
Display Table Demo
Display Table DemoDisplay Table Demo
Display Table Demo
Warawut
 
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
Tobias Philipp
 
C Basics
C BasicsC Basics
C Basics
Sunil OS
 
ตรรกศาสตร์เบื้องต้น
ตรรกศาสตร์เบื้องต้นตรรกศาสตร์เบื้องต้น
ตรรกศาสตร์เบื้องต้น
wanwilai
 
Session and Cookie
Session and CookieSession and Cookie
Session and Cookie
Warawut
 
Field Binding
Field BindingField Binding
Field Binding
Warawut
 

Similar to โครงสร้างภาษาซี1 (20)

ใบความรู้เรื่องคำสั่ง Printf scanf
ใบความรู้เรื่องคำสั่ง Printf scanfใบความรู้เรื่องคำสั่ง Printf scanf
ใบความรู้เรื่องคำสั่ง Printf scanf
 
เขียนโปรแกรมใช้คำสั่ง Printf scanf
เขียนโปรแกรมใช้คำสั่ง  Printf scanfเขียนโปรแกรมใช้คำสั่ง  Printf scanf
เขียนโปรแกรมใช้คำสั่ง Printf scanf
 
C Language Program
C Language ProgramC Language Program
C Language Program
 
9789740333036
97897403330369789740333036
9789740333036
 
9789740333036
97897403330369789740333036
9789740333036
 
การใช้งานโปรแกรม R เบื้องต้น
การใช้งานโปรแกรม R เบื้องต้นการใช้งานโปรแกรม R เบื้องต้น
การใช้งานโปรแกรม R เบื้องต้น
 
ชนิดข้อมูลและตัวแปร
ชนิดข้อมูลและตัวแปรชนิดข้อมูลและตัวแปร
ชนิดข้อมูลและตัวแปร
 
SearchDemo
 SearchDemo SearchDemo
SearchDemo
 
Java Web Service
Java Web ServiceJava Web Service
Java Web Service
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
พื้นฐานการออกแบบโปรแกรม
พื้นฐานการออกแบบโปรแกรมพื้นฐานการออกแบบโปรแกรม
พื้นฐานการออกแบบโปรแกรม
 
หนังสือ Cloning freebsd
หนังสือ Cloning freebsdหนังสือ Cloning freebsd
หนังสือ Cloning freebsd
 
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
Fraction.h #include iostream #ifndef FRACTION #define FR.pdfFraction.h #include iostream #ifndef FRACTION #define FR.pdf
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
 
DataReaderDemo
DataReaderDemoDataReaderDemo
DataReaderDemo
 
Display Table Demo
Display Table DemoDisplay Table Demo
Display Table Demo
 
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
Unsatisfiability Proofs for Parallel SAT Solver Portfolios with Clause Sharin...
 
C Basics
C BasicsC Basics
C Basics
 
ตรรกศาสตร์เบื้องต้น
ตรรกศาสตร์เบื้องต้นตรรกศาสตร์เบื้องต้น
ตรรกศาสตร์เบื้องต้น
 
Session and Cookie
Session and CookieSession and Cookie
Session and Cookie
 
Field Binding
Field BindingField Binding
Field Binding
 

More from ธงชัย พาศรี

ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรม
ธงชัย พาศรี
 
การวิเคราะห์ปัญหา(080653)
การวิเคราะห์ปัญหา(080653)การวิเคราะห์ปัญหา(080653)
การวิเคราะห์ปัญหา(080653)ธงชัย พาศรี
 
การเขียนผังงานแบบทำซ้ำ (080753)
การเขียนผังงานแบบทำซ้ำ  (080753)การเขียนผังงานแบบทำซ้ำ  (080753)
การเขียนผังงานแบบทำซ้ำ (080753)ธงชัย พาศรี
 
การเขียนผังงานแบบทางเลือก (050753)
การเขียนผังงานแบบทางเลือก  (050753)การเขียนผังงานแบบทางเลือก  (050753)
การเขียนผังงานแบบทางเลือก (050753)ธงชัย พาศรี
 
การเขียนผังงานแบบทางเลือก (010753)
การเขียนผังงานแบบทางเลือก  (010753)การเขียนผังงานแบบทางเลือก  (010753)
การเขียนผังงานแบบทางเลือก (010753)ธงชัย พาศรี
 
การเขียนผังงานแบบทางเลือก (050753)
การเขียนผังงานแบบทางเลือก  (050753)การเขียนผังงานแบบทางเลือก  (050753)
การเขียนผังงานแบบทางเลือก (050753)ธงชัย พาศรี
 
การเขียนผังงานแบบทางเลือก (010753)
การเขียนผังงานแบบทางเลือก  (010753)การเขียนผังงานแบบทางเลือก  (010753)
การเขียนผังงานแบบทางเลือก (010753)ธงชัย พาศรี
 

More from ธงชัย พาศรี (10)

ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรม
 
การวิเคราะห์ปัญหา(080653)
การวิเคราะห์ปัญหา(080653)การวิเคราะห์ปัญหา(080653)
การวิเคราะห์ปัญหา(080653)
 
การเขียนผังงานแบบทำซ้ำ (080753)
การเขียนผังงานแบบทำซ้ำ  (080753)การเขียนผังงานแบบทำซ้ำ  (080753)
การเขียนผังงานแบบทำซ้ำ (080753)
 
การเขียนผังงานแบบทางเลือก (050753)
การเขียนผังงานแบบทางเลือก  (050753)การเขียนผังงานแบบทางเลือก  (050753)
การเขียนผังงานแบบทางเลือก (050753)
 
การเขียนผังงานแบบทางเลือก (010753)
การเขียนผังงานแบบทางเลือก  (010753)การเขียนผังงานแบบทางเลือก  (010753)
การเขียนผังงานแบบทางเลือก (010753)
 
การเขียนผังงาน (290653)
การเขียนผังงาน (290653)การเขียนผังงาน (290653)
การเขียนผังงาน (290653)
 
การเขียนผังงาน (280653)
การเขียนผังงาน (280653)การเขียนผังงาน (280653)
การเขียนผังงาน (280653)
 
การเขียนผังงานแบบทางเลือก (050753)
การเขียนผังงานแบบทางเลือก  (050753)การเขียนผังงานแบบทางเลือก  (050753)
การเขียนผังงานแบบทางเลือก (050753)
 
การเขียนผังงานแบบทางเลือก (010753)
การเขียนผังงานแบบทางเลือก  (010753)การเขียนผังงานแบบทางเลือก  (010753)
การเขียนผังงานแบบทางเลือก (010753)
 
การเขียนผังงาน (290653)
การเขียนผังงาน (290653)การเขียนผังงาน (290653)
การเขียนผังงาน (290653)
 

Recently uploaded

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 

Recently uploaded (20)

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 

โครงสร้างภาษาซี1

  • 1. F F
  • 2. F F F F F F Interactive 2
  • 3. F Preprocessor Directives Global Declarations void main(void) { Local Declarations Statements } 3
  • 4. Preprocessor Directives F file F F F (Header File) F Directive # 4
  • 5. Preprocessor Directives Directive F #include Include text from file #define Define a macro #undef Undefine a macro #if Test if a compile-time condition hold #ifdef Test if a symbol is defined #ifndef Test if a symbol is not defined #else Indicate alternatives if a test fails #elif Combination of #if and #else #endif End a preprocessor conditional #line Give a line number for compiler message #error Terminate processing early #pragma Implementation dependent directive 5
  • 6. #include F F Compiler F F F Compile F #include FILE NAME F #include stdio.h F F stdio.h #include conio.h F F conio.h 6
  • 7. #define F F F #define NAME VALUE F #define PI 3.14 F PI F 3.14 #define X 3.14*2 F X F 3.14*2 7
  • 8. Global Declarations F F F F F F F F F F F 8
  • 9. Main () function F F F main() F F F ; F F main() F { F } 9
  • 10. F (Program Comment) F F // comment 1 /* comment 1 */ /* comment F 1 .*/ 10
  • 11. F F F F F F Interactive 11
  • 13. #include stdio.h void main() { printf( Hello World ); // F F Hello World } Hello World 13
  • 14. #include stdio.h void main() { printf( Hellon ); printf( World ); } Hello World 14
  • 15. #include stdio.h void main() { printf( Hellon ); printf( Worldn ); } Hello World  15
  • 16. F F F F F F Interactive 16
  • 17. #include stdio.h PI 3.14 #define PI 3.14 r area void main() { 20.00 0.0 float r = 20.00, circum = 0.0; 125.6 circum = 2 * PI * r; printf( Circumference is %f Radius is %fn , circum,r); } 17
  • 18. F F F F F F Interactive 18
  • 19. F F keyboard scanf(...) monitor printf(...) Memory 19
  • 20. F F F F F printf() putchar() puts() 20
  • 21. F F F F F F scanf() getchar() getch() getche() gets() 21
  • 22. F F F F F printf() putchar() puts() 22
  • 23. F printf F F F F F #include stdio.h printf(“Control String”,arg1,arg2,arg3,..); printf(“Control String”); 23
  • 24. printf(“%dn%d”,a,b); %dn%d a,b Memory a 22 b 30 22 22 -> 30 . 30 Output Stream 24
  • 25. F printf : F printf( Computer Programming 1 ); printf( ComputernProgramming 1 ); printf( Result is %f ,area); printf( Result isn%f ,area); 25
  • 26. F printf : F F 10 + 3 F START X (1. F 10 + 3 X) 1. X = 10 +3 X = 10 + 3 (2. F X ) 2. PRINT 10 + 3 PRINT X PRINT X END 26
  • 27. F printf : F n F t F 6 r cursor F F f F 1 F b cursor 1 F F a F F F 27
  • 28. F printf : F F %d F F %ld F F long int %u F F F %f F F float %lf F F double %Lf F F long double %e F F %c F F (char) %s F F (string) F %% F F % %o F F %x F F %p F F address pointer 28
  • 29. F printf : F int j=45, k = -123; printf(“Hellon”); float x = 12.34 printf(“Tax is 10%%n”); char c = ‘A’; printf(“%dn”,j); char *m = “Hello”; char mm[6] = “Hello” ; printf(“%dn”,k); printf(“%fn”,x); printf(“%6.2fn”,x); printf(“%cn”,c); printf(“%dn”,c); 29
  • 30. F printf : F int j=45, k = -123; printf(“%dn”,c+1); float x = 12.34 printf(“%cn”,c+1); char c = ‘A’; printf(“%sn”,m); char *m = “Hello”; printf(“%sn”,mm); char mm[6] = “Hello” ; printf(“%en”,x); printf(“%En”,x); 30
  • 31. F printf : F 31
  • 32. F printf : F F %d %4d 12 12 12 123 123 123 1234 1234 1234 12345 12345 12345 32
  • 33. #include stdio.h #include stdio.h void main() { void main() { printf( Yesn ); printf( Yesn ); printf( Non ); printf( n ); } printf( Non ); } 33
  • 34. #include stdio.h #include stdio.h void main() { void main() { printf( Yes ); printf( YesnNo ); printf( No ); } } 34
  • 35. #include < stdio.h > void main ( ) { // number F int number; // F 8 F number number = 8; printf ( The value of number is %d . , number); } The value of number is 8 . 35
  • 36. #include stdio.h Circumference is 125.6  #define PI 3.14 void main() { float r = 20.00, circum = 0.0; circum = 2 * PI * r; printf( Circumference is %.1fn , circum); } 36
  • 37. #include stdio.h #define PI 3.14 void main ( ) { float r, area; printf ( This program computes the area of a circlen ); r = 12.5; /* F F 12.5 */ area = PI * r * r; /* = ¶ r2 */ printf ( Area = Pi x radius x radiusn ); printf ( = %.2f x %.2f x %.2fn , PI, r, r); printf ( = %fn , area); This program computes the area of a circle Area = Pi x radius x radius = 3.14 x 12.50 x 12.50 = 490.873444  37
  • 38. #include < stdio.h > #define SIXTY 60 /* SIXTY F F F */ void main ( ) { float hour; // hour F F int minute, second; // 2 F hour = 1.5; // F 1.5 F hour // F hour F 60 F F F minute minute = hour * SIXTY; // F minute F 60 F F F second second = minute * SIXTY; printf ( In one period : n %.2f hoursn , hour); printf ( %d minutesn%d seconds , minute, second); } In one period : 1.50 hours 90 minutes 5400 seconds 38
  • 39. F F F F F printf() putchar() puts() 39
  • 40. F putchar F 1 F #include stdio.h putchar(variable); 40
  • 41. F putchar : F #include “stdio.h” void main ( ) { char s; s = ‘A’; putchar(s); } A 41
  • 42. F F F F F printf() putchar() puts() 42
  • 43. F puts F F F F F 1 variable F F F F F1 puts(variable); 43
  • 44. F puts : F #include “stdio.h” #include<string.h> void main ( ) { char str[30]; str = “C Programming”; strcpy(str,”C programming”); puts(str); printf(“nOutput = %sn”,str); } C Programming Output = C Programming  44
  • 45. F F F F F F scanf() getchar() getch(), getche() gets() 45
  • 46. F scanf F F F F F Enter F F F F F F include stdio.h scanf(“Control String”,&arg1,&arg2,&arg3,..); 46
  • 47. scanf(“%d%f”,&a,&b); %d%f a,b 22 30 . a 22 b 30 Input Stream int a; float b; scanf( %d%f ,&a,&b); 47
  • 48. F Scanf : F int num; scanf( %d ,&num); printf( the value in num variable is %d ,num); char str[80]; printf( Enter a string : ); scanf( %s ,str); printf( Here s your string : %s , str); 48
  • 49. #include < stdio.h > void main ( ) { int years; printf ( How long have you been here? ); scanf ( %d , &years); printf ( You ve been here for %d years. , years); printf ( tReally? ); } How long have you been here? 20 You’ve been here for 20 years. Really? 49
  • 50. F F F F F F scanf() getchar() getch() ,getche() gets() 50
  • 51. F getchar F F F F 1 F F 1 Enter F F F F ch = getchar(); 51
  • 52. F getchar : F #include “stdio.h” void main ( ) { char ch; ch = getchar(); printf(“The Character you typed is %cn”, ch); } d The Character you typed is d 52
  • 53. F F F F F F scanf() getchar() getch(),getche() gets() 53
  • 54. F getch(),getche() F F 1 F F F F F Enter ch = getch(); F F 1 F F F F Enter ch = getche(); F #include<conio.h> 54
  • 55. F getch : F #include “stdio.h” #include “conio.h” void main ( ) { char ch; ch = getch(); printf(“The Character you typed is %cn”, ch); } The Character you typed is d 55
  • 56. F F F F F F scanf() getchar() getch() gets() 56
  • 57. F gets F F F F F F F Enter F F F F F F F F gets(variable); 57
  • 58. F gets : F #include “stdio.h” void main ( ) { char str[51]; gets(str); printf(“The Message you typed is %sn”, str); } test The Message you typed is test 58
  • 59. F F F F F F Interactive 59
  • 60. Interactive F F F F F F F F F F F F F F F F F F F F 60