--




33
C
8-
11
-


-       18
Mind Map         19




-   -        -
(array)     array


                                    index)




     1.           1       one dimension arrays         single
dimension
arrays)
    word[20] ,num[25] , x[15]
     2.                       multi-dimension arrays



          2.1             2                     2
     a[3][5] , name[5][6]
          2.2             3                     3
     a[3][5][6] , name[5][6][8]
Type arrayname[size];
        type                                int char float
        arrayname                          array
        size
                                                              int a[12];
                         array         a       array
integer                                         a[0] a[1] a[2] a[3] …
a[11]




                                               array



integer                array



                               array



        int num1[3]={56,25,89};                                num1
   array           integer
                       num1[0]=56;              num1[1]=25;        nu
m1[2]=89;
int                                                     a[
]={200,230};                    a             array          integer
                                                             a[0]
    200            a[1]          230


                                       int          value[             ]
;
                                                    {
}                                             ,
             int          a[   ]={200,230};
                                                                    int
money[5];
    money[0] = 250; money[4] = 500;
     float num[5];                                 array
                               float         num
    num[0]                                                   num[1]…
num[4]




                                                    array
4
                                           4       5       20
   num[ ]                  2.00      num[3]                55.52      num[1] ,
num[2]           num[4]                                                   array
         float                                 array            integer
                                                                {}
                           ,


                 Float                         num[5]                             =
{2.00,1.25,5.36,6.32,246.10};                              num[0]                 =
2.00                 num[1]          =         1.25             num[2]            =
5.36              num[3] = 6.32            num[4] = 246.10


                 float salary[10];
                 salary[0] = 25000.00;
                 salary[9] = 55600.00;
        char
a[12];                                   array         a     array
                    char                       2             a[0]    a[1]     …
a[11]
char


                                          1
array          char                        12        x    1      12
bytes                           array
                                                              string
variable)                                      integer   float


                                          2         two dimension
arrays)
     array 2
                                        row)
                      column)
array         x[6]




                                            array
       array
                                        x
                             array 2                array        array




                                            array


               array                    table[0]
table[1]       table[2]                             array
     table           array      table
             array                   table[0][0] , table[0][1]
…      table[2][3]
table[0][0]                                                       array
                     type arrayname [r] [c];
              type                              int , float ,char
              arrayname                   array            num , word ,x
              r,c
                                                                 r        0,1,2
…      ,    r-1           c      0,1,2      …          ,   c-1                int
num[3][4];                        array           integer
                                                                     num[0][0],
num[0][1] ,num[0][2],num[0][3],num[1][0],…,num[2][3]


              char            word[               ][             ]             =
{“Bodin”,”decha”,”Computer”,”Pentium”};
word                 array                                                     x
9
    word[0] = “Bodin”           word[1] = “dehca” word[2] =
“Computer”                word[3]     =     “Pentium“


              int num[2][2];
              num[0][1]=3;
           array 3
       type arrayname[p] [r][c];
       type                               int ,float,char
       arrayname
r,c,p
     array


      p       0,1,2 .. , p-1
      r       0,1,2, … ,r-1
      c       0,1,2 … ,c-1
                                   array
                                                arrays   of
arrays




                                           array 3


      table
[3][5][4]              table[5][4][3]
array of arrays




                                                   array
           table[3][4][5]
table[0][0][0]      table[0][0][0]                  table[0][0]
table[0][0]      table[0][4]
                 table[0]       table[0]      table[2]             tab
le            table[3[[5][4]                               array   r *c
*p      array
                                           array
        array                  array



                   array                   array
type arrayname[ ]…[ ]
                               array




                                   type arrayname




array5_1.c
                     array



/* array5_1.c */
#include <stdio.h>
#include <conio.h>
main()
{
    clrscr();
    float num[50];
    float sum;
    int i,time;
    printf(”n Enter the time of input that you want. :”);
    scanf(”%d”,&time);
sum = 0;
    for (i=0;(i+1)<=time;i++)
    {
        printf(”Please type the floating number for %d round
:”,i+1);
        scanf(”%f”,&num[i]);
        sum = sum + num[i];
    }
        printf(”n Input = %d time sum.of them =
%4.2f average of data is%4.2f”, time , sum , sum/time) ;
}




array5_2.c
                      array



/* array5_2.c */
#include <stdio.h>
#include <conio.h>
main()
{
        clrscr();
        float num[5][4] ;
char name[5][20] ={ “Chattam Sermsub”,”Sompol
Somsuk”,”Kanokporn                       Kanok”,             “Apinya
Sittipa”,”Wimolsiri Sirimol”};
        int time,i,j;
        num[0][0] = 1.0; num[0][1] = 1.5; num[0][2] = 2.0;
num[0][3] = 2.5;                  num[1][0] = 1.5; num[1][1] = 2.0;
num[1][2] = 2.5; num[1][3] = 3.0;
        num[2][0] = 1.0; num[2][1] = 1.5; num[2][2] =
2.0; num[2][3] = 2.5;
        num[3][0]=       1.5;   num[3][1]   =   2.0;    num[3][2]    =
2.5;     num[3][3] = 3.0;
        num[4][0]=       1.5;   num[4][1]   =   2.0;    num[4][2]    =
2.5;     num[4][3] = 3.0;
        printf(”Enter number of Student :”);
        scanf(”%d”,&time);
        for (i=0;(i+1)<=time;i=i+1)
{
        printf(”n      Student    no.   %d        is   %s   t     has
num.”,i+1,name[i]);
        for (j=0;(j+1)<=4;j++)
        printf(”, %4.2f “,num[i][j]);
    }
}
1.




                                            for




for (n =   ; n <=    ; n++)
{
printf ( “ Score = “ ) ;
scanf ( “ %d “ , &score [ n ] ) ;
}



                                    score
           scanf
n




for (n = ; n <         ; n++)
{
}
for (m =       ; m <=     ; m++)
{
printf ( “ Score = “ ) ;
scanf ( “ %d “ , &score [ n ] [ m] ) ;
}
                                                          for




    2.




         type array_name [ size] = { value list } ;


         type array_name [ r ] [ c ] = { value list } ;
type array_name [ n ] [ r ] [ c ] = { value list } ;


          type                              int, float, char
          array_name
          size
          value list
          ,
           n]
           r]
           c]



                           ,   ,   ,   ,
a[         =
a[         =
a[         =


a[         =
a[         =


int a [          {     ,       ,   ,   ,   };


     3.



printf (“ %d” , a[             ;
for (n =   ; n <=    ; n++)
{
printf ( “ Score = %d n” , score [ n ] ) ;
}


                                                           score
                             printf   “ Score = %d n” , score [ n
]);
                       n




for (n =   ;n<      ; n++)
{
}
for (m = ; m <       ; m++)
{
}
for (p = ; p <      ; p++)
{
num = score [ n ] [m] [p] ;
printf (“ %d  t  t “ , num );
    }



                                       (Strings)
                           String constants)
                                  “”
        “ Computer ” , “ TAMMANOON ” “ mile ”, “ 123456 ”
                            (String                     variables)
            array)
                                   char       char word[3] = “Ok”
;                  char                 speech[2][20]                =
{”Hello”,Thailand”};



                                                   null     character
(0)



               1
             char arrayname[c];
             char arrayname[c] = “string constants”;
            arrayname
        c
        string constants
2
           char arrayname[r][c];
           char          arrayname[r][c]      =       {”string
constants0″,”string constants1,…,”string
      constants(r-1)};
          arrayname
          r
          c
      string constants
                           r-1
r                                                     c-
                                                  assignment
(=)
                                   arrayname[2][10]         =
{”Bodin”,”12345d,”food};


                   for , while ,do while




array5_3.c
/* array5_3.c */
#include <stdio.h>
#include <conio.h>
main()
{
     clrscr();
     char name[50][50],changwad[50][30] ; int time,i,j;
     printf(”Enter      number            of          Student       :”);
scanf(”%d”,&time); i =0;
     while (i<=(time-1)) {
     printf(”n Enter name of %dth person :”,i+1);
     scanf(”%s”,name[i]);
     printf(”n Enter changwad of %dth person :”,i+1);
     scanf(”%s”,changwad[i]); i++;             }
     for (j=0;(j+1)<=time;j++)
     printf(”n Name of %dth person is %s who live in
%s.”,j+1,name[j],changwad[j]);
}




                 4           strlen() ,
strcmp(),strcpy(),strcat()                                      string.
h                                                  #include <string.h>


strlen()


     strlen(”string constant”);      strlen(string variables);
strlen1.c                              strlen()
/* strlen1.c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
char word[100]; int length;
void main(void)
{
    clrscr();
                  printf(”Please              enter            your
strings.”);     gets(word);        length = strlen(word);
    printf(”Your strings       is %s.”,word);          printf(”nThe
length of strings is %d”,length);
}


                   strcmp()                            2


              strcmp(stringvariable1,stringvariable2);
              strcmp(stringconstant1,stringconstant2);


                           ASCII
1                             2
                          1
                           1                             2
                   0
                           1                             2
                          1




strlcmp1.c                          strcmp()
/* strcmp1.c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
char word[100],password[100]={”Bodin”};
int compareresult;
void main(void)
{
     clrscr();
     printf(”Please enter your strings.”);
     gets(word);
     compareresult = strcmp(password,word);
     if (compareresult > 0)
     {printf(”Your     strings    <      Program   strings.
compareresult is %d”,compareresult);}
     else if (compareresult == 0)
{printf(”Your strings = Program strings. compareresult
is %d”,compareresult);}
      else
      {printf(”Your strings > Program strings. compareresult
is %d”,compareresult);}
}



strcpy()
                                           Strcpy(string2,string1);
                      string1       string2


                                 strcpy
/* strcpy c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
      char word        ,word        ;     clrscr();
      printf(”Please       enter        your st       strings     :
“);      gets(word ;
      printf(”Enter your nd strings : “);         gets(word ;
      printf(”n st    strings    are     :%s   nd    strings   are
:%s”,word ,word ;
strcpy(word ,word ;
      printf(”n st      strings   are         :%s       nd   strings   are
:%s”,word ,word ;
}


                             strcat()


                                          strcat(string2          ,string1);


string1                                        string2
/* strcat c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
      Char word          ,word          ; clrscr () ; printf ( “ Please enter
your st strings: ” ) ;   gets ( word       ;
       printf(”Enter your nd strings : “);               gets(word ;
      printf(”n st      strings   are         :%s       nd   strings   are
:%s”,word ,word ;            strcat(word ,word ;
      printf(”n st      strings   are         :%s       nd   strings   are
:%s”,word ,word ;
}
char, int, long,
float, double, unsigned int, unsigned long int,
       •                            2
              1.
                        Global Variable


                   0(
              2.
                        Local Variable



       •
                             ,            ,     ,.....;
       •
              1.
char                                                         1
                                    1
‘A’ , ‘b’ , ‘1’ , ‘?’
              2.
integer
                         -32768     32767                   2


             5-         10 2534
3.
  long                                                    2
                                                          long
  int )
             4.
  float
            a.b x 10e                 4
  3.4E-38      3.4E+38                                        6
                                   10.625 -6.67
             5.
  double                                                  float
                                          2                8
                      1.7E-308   1.7E+308
             6.
  unsigned



             unsigned int




Char              8              ASCII character (-128         127)

Unsignedchar      8              0-255

Int               16             -32768       32767

long int          32             -2147483648          2147483649
3.4E-38           3.4E+38
Float           32
                                            6

                                  1.7E-308          1.7E+308
Double          64
                                            12

Unsigned int    16                0    65535

Unsigned long
                32                0    4294967296
int


          1
               1. #include<stdio.h>
               2. #define PI 3.14159
               3. int area; /* global variable */
               4. main( )
               5. { float radius; /* local variable */
               6. float process() /* function declaration */
               7. printf (“Radius = ?”); scanf (“%f”,radius);
               8. process( );
               9. printf(“Area = %f”,area);
               10. printf(“%f”,radius); }
               11. float process( )
               12. { float radius; /* local variable */
               13 printf(“Radius=?”); scanf (“%f”,radius);
               14 area=PI*radius*radius;
15 printf(“Area = %f”,area);
               16 printf(“%f”,radius); }


          2 int a ;
                                      a


 -35768        32767


          3 int num1=8;
                                      num1
                                                          8


          4 float money,price ;
                      money       price


                                      6


          5 char ch=’A’
                                      ch
                                  1               ‘A’



     char a,b,c,d; /*         a,b,c,d
character */
     unsigned e; /*           e               unsigned int */
char key = ?A?; /*     key
character    ?A? */
    char name = ?SAM? /*         name
character   ”SAM” */
รายงานคอม
“             ”




     “       ”
     type        array        float          salary
3.




             float




     float           double           char        long
8.
     float           double           char        long
array




char
double
http://courseware.bodin.ac.th/computer/AdvancedLev
el4/programming/C_language/5.htm
    http://www.no-
poor.com/CandDelphi/ch5_array_and_pointer.htm
    http://202.143.168.214/uttvc/website/07.html

More Related Content

DOCX
รายงานคอม
PDF
C# v8 new features - raimundas banevicius
PDF
01 derivadas
PDF
Mary Had a Little λ (QCon)
PDF
[1062BPY12001] Data analysis with R / week 2
PDF
SVGo workshop
PDF
The Ring programming language version 1.5.1 book - Part 23 of 180
PPT
Chapter2
รายงานคอม
C# v8 new features - raimundas banevicius
01 derivadas
Mary Had a Little λ (QCon)
[1062BPY12001] Data analysis with R / week 2
SVGo workshop
The Ring programming language version 1.5.1 book - Part 23 of 180
Chapter2

What's hot (18)

PPTX
JavaFX and Scala - Like Milk and Cookies
PDF
FunScript 2013 (with speakers notes)
PDF
Quadratic functions and models
KEY
Gazr
PDF
The Ring programming language version 1.10 book - Part 40 of 212
PDF
Objective-C for Java developers
PPTX
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
PDF
Formulario de calculo
KEY
AP Calculus - Tutorial
PDF
Linear algebra-solutions-manual-kuttler-1-30-11-otc
DOC
Mathematics
PDF
Ism et chapter_3
PPT
Cleaner APIs, Cleaner UIs with Visage (33rd Degrees)
PPT
SDC - Einführung in Scala
PPTX
하스켈 프로그래밍 입문 3
PDF
Actividad 4 calculo diferencial
PPTX
Python object oriented programming (lab2) (2)
JavaFX and Scala - Like Milk and Cookies
FunScript 2013 (with speakers notes)
Quadratic functions and models
Gazr
The Ring programming language version 1.10 book - Part 40 of 212
Objective-C for Java developers
Hacking JavaFX with Groovy, Clojure, Scala, and Visage
Formulario de calculo
AP Calculus - Tutorial
Linear algebra-solutions-manual-kuttler-1-30-11-otc
Mathematics
Ism et chapter_3
Cleaner APIs, Cleaner UIs with Visage (33rd Degrees)
SDC - Einführung in Scala
하스켈 프로그래밍 입문 3
Actividad 4 calculo diferencial
Python object oriented programming (lab2) (2)
Ad

Viewers also liked (17)

PDF
3 g modem_tutorial
DOCX
ข่าวไอที
DOCX
ตอบคำถาม โรงเรียนในฝัน
DOCX
เลอโนโวเข็นโน้ตบุ๊กลูกผสมแท็บเล็ต
DOC
Chua essay
PPT
ตัวแปรชุดและตัวแปรอักขระ PPT
PPT
Unit 13 speaking revised
DOC
ตัวแปรชุดและตัวแปรอักขระ
PPT
ตัวแปรชุดและตัวแปรอักขระ
DOCX
โรงเรียนในฝัน
DOCX
ตอบคำถาม โรงเรียนในฝัน
PPT
ตัวแปรชุดและตัวแปรอักขระ
PDF
108 วิธี.. เรียนเก่ง โครต...โครต
PPT
Slide nghiên cứu seo
DOCX
ประกวด
DOCX
งานย่อย1 ประกวด
DOCX
ประกวด
3 g modem_tutorial
ข่าวไอที
ตอบคำถาม โรงเรียนในฝัน
เลอโนโวเข็นโน้ตบุ๊กลูกผสมแท็บเล็ต
Chua essay
ตัวแปรชุดและตัวแปรอักขระ PPT
Unit 13 speaking revised
ตัวแปรชุดและตัวแปรอักขระ
ตัวแปรชุดและตัวแปรอักขระ
โรงเรียนในฝัน
ตอบคำถาม โรงเรียนในฝัน
ตัวแปรชุดและตัวแปรอักขระ
108 วิธี.. เรียนเก่ง โครต...โครต
Slide nghiên cứu seo
ประกวด
งานย่อย1 ประกวด
ประกวด
Ad

Similar to รายงานคอม (20)

PPTX
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
PPTX
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
PPTX
Array in c language
PPT
Unit3 jwfiles
PPT
C Language Unit-3
PPT
Multi dimensional arrays
PDF
Introduction to NumPy
PDF
Introduction to NumPy (PyData SV 2013)
PPTX
2- Dimensional Arrays
PPTX
C-Programming Arrays.pptx
PPTX
C-Programming Arrays.pptx
PPT
Lecture 15 - Array
PPT
PPTX
C (PPS)Programming for problem solving.pptx
PPTX
Arrays in Java
PPTX
Data Structures - Lecture 3 [Arrays]
PDF
7. arrays
PPT
Use syntax highlighting for C++ code (via plugins like "Highlight Code" for P...
PPT
ReviewArrays.ppt
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
Array in c language
Unit3 jwfiles
C Language Unit-3
Multi dimensional arrays
Introduction to NumPy
Introduction to NumPy (PyData SV 2013)
2- Dimensional Arrays
C-Programming Arrays.pptx
C-Programming Arrays.pptx
Lecture 15 - Array
C (PPS)Programming for problem solving.pptx
Arrays in Java
Data Structures - Lecture 3 [Arrays]
7. arrays
Use syntax highlighting for C++ code (via plugins like "Highlight Code" for P...
ReviewArrays.ppt

More from Areeya Onnom (20)

DOCX
งานย่อย1
DOCX
Nokia Lumia 920
DOCX
'ไทยรัฐ ฟอร์ ไอแพด'
DOC
แท็บเล็ต
DOC
Google เตรียมทดสอบ
DOCX
it news
DOCX
คำแนะนำชมเชย
DOCX
คำแนะนำศักดิ์ศรัณย์
DOCX
คำแนะนำภานุพงศ์
DOCX
โรงเรียนในฝัน
DOCX
งาน 9 สุภาพร
DOCX
งาน 9 อังสนา
DOCX
คำแนะนำสุภาพร
DOCX
คำแนะนำอังสนา
DOCX
คำแนะนำ
DOCX
คำแนะนำ
DOCX
งาน 9
DOCX
งาน 9
DOCX
งาน 9
DOCX
it news
งานย่อย1
Nokia Lumia 920
'ไทยรัฐ ฟอร์ ไอแพด'
แท็บเล็ต
Google เตรียมทดสอบ
it news
คำแนะนำชมเชย
คำแนะนำศักดิ์ศรัณย์
คำแนะนำภานุพงศ์
โรงเรียนในฝัน
งาน 9 สุภาพร
งาน 9 อังสนา
คำแนะนำสุภาพร
คำแนะนำอังสนา
คำแนะนำ
คำแนะนำ
งาน 9
งาน 9
งาน 9
it news

รายงานคอม

  • 2. C
  • 4. - - 18 Mind Map 19 - - -
  • 5. (array) array index) 1. 1 one dimension arrays single dimension arrays) word[20] ,num[25] , x[15] 2. multi-dimension arrays 2.1 2 2 a[3][5] , name[5][6] 2.2 3 3 a[3][5][6] , name[5][6][8]
  • 6. Type arrayname[size]; type int char float arrayname array size int a[12]; array a array integer a[0] a[1] a[2] a[3] … a[11] array integer array array int num1[3]={56,25,89}; num1 array integer num1[0]=56; num1[1]=25; nu m1[2]=89;
  • 7. int a[ ]={200,230}; a array integer a[0] 200 a[1] 230 int value[ ] ; { } , int a[ ]={200,230}; int money[5]; money[0] = 250; money[4] = 500; float num[5]; array float num num[0] num[1]… num[4] array
  • 8. 4 4 5 20 num[ ] 2.00 num[3] 55.52 num[1] , num[2] num[4] array float array integer {} , Float num[5] = {2.00,1.25,5.36,6.32,246.10}; num[0] = 2.00 num[1] = 1.25 num[2] = 5.36 num[3] = 6.32 num[4] = 246.10 float salary[10]; salary[0] = 25000.00; salary[9] = 55600.00; char a[12]; array a array char 2 a[0] a[1] … a[11]
  • 9. char 1 array char 12 x 1 12 bytes array string variable) integer float 2 two dimension arrays) array 2 row) column)
  • 10. array x[6] array array x array 2 array array array array table[0] table[1] table[2] array table array table array table[0][0] , table[0][1] … table[2][3]
  • 11. table[0][0] array type arrayname [r] [c]; type int , float ,char arrayname array num , word ,x r,c r 0,1,2 … , r-1 c 0,1,2 … , c-1 int num[3][4]; array integer num[0][0], num[0][1] ,num[0][2],num[0][3],num[1][0],…,num[2][3] char word[ ][ ] = {“Bodin”,”decha”,”Computer”,”Pentium”}; word array x 9 word[0] = “Bodin” word[1] = “dehca” word[2] = “Computer” word[3] = “Pentium“ int num[2][2]; num[0][1]=3; array 3 type arrayname[p] [r][c]; type int ,float,char arrayname
  • 12. r,c,p array p 0,1,2 .. , p-1 r 0,1,2, … ,r-1 c 0,1,2 … ,c-1 array arrays of arrays array 3 table [3][5][4] table[5][4][3]
  • 13. array of arrays array table[3][4][5] table[0][0][0] table[0][0][0] table[0][0] table[0][0] table[0][4] table[0] table[0] table[2] tab le table[3[[5][4] array r *c *p array array array array array array
  • 14. type arrayname[ ]…[ ] array type arrayname array5_1.c array /* array5_1.c */ #include <stdio.h> #include <conio.h> main() { clrscr(); float num[50]; float sum; int i,time; printf(”n Enter the time of input that you want. :”); scanf(”%d”,&time);
  • 15. sum = 0; for (i=0;(i+1)<=time;i++) { printf(”Please type the floating number for %d round :”,i+1); scanf(”%f”,&num[i]); sum = sum + num[i]; } printf(”n Input = %d time sum.of them = %4.2f average of data is%4.2f”, time , sum , sum/time) ; } array5_2.c array /* array5_2.c */ #include <stdio.h> #include <conio.h> main() { clrscr(); float num[5][4] ;
  • 16. char name[5][20] ={ “Chattam Sermsub”,”Sompol Somsuk”,”Kanokporn Kanok”, “Apinya Sittipa”,”Wimolsiri Sirimol”}; int time,i,j; num[0][0] = 1.0; num[0][1] = 1.5; num[0][2] = 2.0; num[0][3] = 2.5; num[1][0] = 1.5; num[1][1] = 2.0; num[1][2] = 2.5; num[1][3] = 3.0; num[2][0] = 1.0; num[2][1] = 1.5; num[2][2] = 2.0; num[2][3] = 2.5; num[3][0]= 1.5; num[3][1] = 2.0; num[3][2] = 2.5; num[3][3] = 3.0; num[4][0]= 1.5; num[4][1] = 2.0; num[4][2] = 2.5; num[4][3] = 3.0; printf(”Enter number of Student :”); scanf(”%d”,&time); for (i=0;(i+1)<=time;i=i+1) { printf(”n Student no. %d is %s t has num.”,i+1,name[i]); for (j=0;(j+1)<=4;j++) printf(”, %4.2f “,num[i][j]); } }
  • 17. 1. for for (n = ; n <= ; n++) { printf ( “ Score = “ ) ; scanf ( “ %d “ , &score [ n ] ) ; } score scanf
  • 18. n for (n = ; n < ; n++) { } for (m = ; m <= ; m++) { printf ( “ Score = “ ) ; scanf ( “ %d “ , &score [ n ] [ m] ) ; } for 2. type array_name [ size] = { value list } ; type array_name [ r ] [ c ] = { value list } ;
  • 19. type array_name [ n ] [ r ] [ c ] = { value list } ; type int, float, char array_name size value list , n] r] c] , , , , a[ = a[ = a[ = a[ = a[ = int a [ { , , , , }; 3. printf (“ %d” , a[ ;
  • 20. for (n = ; n <= ; n++) { printf ( “ Score = %d n” , score [ n ] ) ; } score printf “ Score = %d n” , score [ n ]); n for (n = ;n< ; n++) { } for (m = ; m < ; m++) { } for (p = ; p < ; p++) { num = score [ n ] [m] [p] ;
  • 21. printf (“ %d t t “ , num ); } (Strings) String constants) “” “ Computer ” , “ TAMMANOON ” “ mile ”, “ 123456 ” (String variables) array) char char word[3] = “Ok” ; char speech[2][20] = {”Hello”,Thailand”}; null character (0) 1 char arrayname[c]; char arrayname[c] = “string constants”; arrayname c string constants
  • 22. 2 char arrayname[r][c]; char arrayname[r][c] = {”string constants0″,”string constants1,…,”string constants(r-1)}; arrayname r c string constants r-1 r c- assignment (=) arrayname[2][10] = {”Bodin”,”12345d,”food}; for , while ,do while array5_3.c /* array5_3.c */ #include <stdio.h> #include <conio.h> main()
  • 23. { clrscr(); char name[50][50],changwad[50][30] ; int time,i,j; printf(”Enter number of Student :”); scanf(”%d”,&time); i =0; while (i<=(time-1)) { printf(”n Enter name of %dth person :”,i+1); scanf(”%s”,name[i]); printf(”n Enter changwad of %dth person :”,i+1); scanf(”%s”,changwad[i]); i++; } for (j=0;(j+1)<=time;j++) printf(”n Name of %dth person is %s who live in %s.”,j+1,name[j],changwad[j]); } 4 strlen() , strcmp(),strcpy(),strcat() string. h #include <string.h> strlen() strlen(”string constant”); strlen(string variables);
  • 24. strlen1.c strlen() /* strlen1.c */ #include <stdio.h> #include <conio.h> #include <string.h> char word[100]; int length; void main(void) { clrscr(); printf(”Please enter your strings.”); gets(word); length = strlen(word); printf(”Your strings is %s.”,word); printf(”nThe length of strings is %d”,length); } strcmp() 2 strcmp(stringvariable1,stringvariable2); strcmp(stringconstant1,stringconstant2); ASCII
  • 25. 1 2 1 1 2 0 1 2 1 strlcmp1.c strcmp() /* strcmp1.c */ #include <stdio.h> #include <conio.h> #include <string.h> char word[100],password[100]={”Bodin”}; int compareresult; void main(void) { clrscr(); printf(”Please enter your strings.”); gets(word); compareresult = strcmp(password,word); if (compareresult > 0) {printf(”Your strings < Program strings. compareresult is %d”,compareresult);} else if (compareresult == 0)
  • 26. {printf(”Your strings = Program strings. compareresult is %d”,compareresult);} else {printf(”Your strings > Program strings. compareresult is %d”,compareresult);} } strcpy() Strcpy(string2,string1); string1 string2 strcpy /* strcpy c */ #include <stdio.h> #include <conio.h> #include <string.h> main() { char word ,word ; clrscr(); printf(”Please enter your st strings : “); gets(word ; printf(”Enter your nd strings : “); gets(word ; printf(”n st strings are :%s nd strings are :%s”,word ,word ;
  • 27. strcpy(word ,word ; printf(”n st strings are :%s nd strings are :%s”,word ,word ; } strcat() strcat(string2 ,string1); string1 string2 /* strcat c */ #include <stdio.h> #include <conio.h> #include <string.h> main() { Char word ,word ; clrscr () ; printf ( “ Please enter your st strings: ” ) ; gets ( word ; printf(”Enter your nd strings : “); gets(word ; printf(”n st strings are :%s nd strings are :%s”,word ,word ; strcat(word ,word ; printf(”n st strings are :%s nd strings are :%s”,word ,word ; }
  • 28. char, int, long, float, double, unsigned int, unsigned long int, • 2 1. Global Variable 0( 2. Local Variable • , , ,.....; • 1. char 1 1 ‘A’ , ‘b’ , ‘1’ , ‘?’ 2. integer -32768 32767 2 5- 10 2534
  • 29. 3. long 2 long int ) 4. float a.b x 10e 4 3.4E-38 3.4E+38 6 10.625 -6.67 5. double float 2 8 1.7E-308 1.7E+308 6. unsigned unsigned int Char 8 ASCII character (-128 127) Unsignedchar 8 0-255 Int 16 -32768 32767 long int 32 -2147483648 2147483649
  • 30. 3.4E-38 3.4E+38 Float 32 6 1.7E-308 1.7E+308 Double 64 12 Unsigned int 16 0 65535 Unsigned long 32 0 4294967296 int 1 1. #include<stdio.h> 2. #define PI 3.14159 3. int area; /* global variable */ 4. main( ) 5. { float radius; /* local variable */ 6. float process() /* function declaration */ 7. printf (“Radius = ?”); scanf (“%f”,radius); 8. process( ); 9. printf(“Area = %f”,area); 10. printf(“%f”,radius); } 11. float process( ) 12. { float radius; /* local variable */ 13 printf(“Radius=?”); scanf (“%f”,radius); 14 area=PI*radius*radius;
  • 31. 15 printf(“Area = %f”,area); 16 printf(“%f”,radius); } 2 int a ; a -35768 32767 3 int num1=8; num1 8 4 float money,price ; money price 6 5 char ch=’A’ ch 1 ‘A’ char a,b,c,d; /* a,b,c,d character */ unsigned e; /* e unsigned int */
  • 32. char key = ?A?; /* key character ?A? */ char name = ?SAM? /* name character ”SAM” */
  • 34. ” “ ” type array float salary 3. float float double char long 8. float double char long
  • 36. http://courseware.bodin.ac.th/computer/AdvancedLev el4/programming/C_language/5.htm http://www.no- poor.com/CandDelphi/ch5_array_and_pointer.htm http://202.143.168.214/uttvc/website/07.html