SlideShare a Scribd company logo
1 of 37
1.         1    (One
    Dimensional Array)
                      []
                           subscript



type array-name[n];
type
array-name

n
char number[5];
int time[3];
float interest[2];
     number, time       interest

                              subscript

scanf(“%d”,&time[1]);
printf(“%fn”,interest[0]);
                                          2(
time[1])                time
              1(         interest[0])
interest
char number[5];


5x1 = 5
    char                 5
number[0], number[1], number[2],
number[3]     number[4]
       number
            1000
int time[3];

                                         3x2 = 6
                                int
3           time[0], time[1]   time[2]
          time
2000
time[0]                         2000+(0x2) = 2000
time[1]                         2000+(1x2) = 2002
time[2]                         2000+(2x2) = 2004
float interest[2];

                                    2x4 = 8
                             float
   2        interest[0]   interest[1]
       interest
3000
interest[0]                      3000+(0x4) =
3000
      interest[1]
3000+(1x4) = 3004
2.         2    (Two
Dimensional Array)

               []2
                     Matrix
           2
type array-name[r][c];
type
array-name
r
c
int score[3][2];
                      3x2 = 6
    score
score[0][0] score[0][1]
score[1][0] score[1][1]
score[2][0] score[2][1]



char person[10][5][80];
int incomes[3][5][2];
float marks[2][4][20];
3.
              (Array Initialization)
                       declare
             1
char msg1[ ] = “Give value for x”;
int x1[ ] = {10,2,8};
float y1[ ] = {12.8,11.3,9.2,6.35};
2
char msg2[ ][40] = {{“SOONTORN”},
“BANGKOK”},
{“AMORN”},
{“CHONBURI”},
       {“PRAPAI”},
       {“KHONKAEN”}};
int x2[ ][3] = {{10,2,8},{5,15,7}};
float y2[ ][4] = {12.8,11.3,9.2,6.35,
2.28,31.3,19.2,86.5,
       12.0,17.43,7.12,62.3};
2



                1
           1                                          5

#include<stdio.h>
void main( ) {
int room_no[ ] = {22, 18, 20, 24, 21};
int total = 0, n = 0;
do {
          total = total + room_no[n];
printf(“Room %d has %3d pupilsn”,n+1,room_no[n]);
n++;
} while(n<5);
printf(“ = = = n”);
          printf(“Total no is %3d pupilsn”,total);
(arrays)   (string)
1)
            100
                   100
int k1, k2, k3, …, k100; /*              k1, k2, k3,
…, k100          100       */
                                                100
                                subscript

int k[100]; /*                  1                      k
*/

2)                                  (table)
                     2
3)
1                 (arrays variables)



    (subscript)
1.1


1)           1      (one dimension
arrays       single dimension arrays)
    1
      (subscript)      1          a[20],
b[100], name[30]       salary[20]
2)                 (multi-
dimension arrays)
               (subscript)           2

2         3

     -
         2      (two dimension arrays)
                             (subscript) 2
          a[2][4], b[3][4], name[5][30]
     -
         3       (three dimension arrays)
                                (subscript)   3
         a[2][3][4], b[3][4][5]
2                       (declaration of
arrays)
1)
    1       (declaration of one dimension
arrays)




type                          int, float, char,
double
arrayname

size
1
     5.1 int s[20];




              2 bytes 20
40 bytes
5.2 char p[20];




            1 bytes 20
20 bytes
5.3 float t[20];




          4 bytes 20
     80 bytes
2)                       2
     (declaration of two dimension arrays)




type                          int, float, char,
double
arrayname

n                                row)             0, 1,
2, …, n-1
m                                      column)
2
               int r[3][2];




                            2
  (table)            n = 0, 1, 2
    m = 0, 1

2 bytes                6
1                  2


                  1
                                      =
        (size)
                  2
                                      = n*m
                      int r[3] [2];        n =
3, m = 2
   = 3*2 = 6
    r[0][0], r[0][1], r[n-1][m-1]
        6
3)                     3
(declaration of three dimension arrays)

 type arrayname [n] [m] [p];


type                           int, float, char,
double
arrayname

n                    1          0, 1, 2, …., n-1
m                    2          0, 1, 2, …., m-
1
p                     3           0, 1, 2, …., p-1
3
                        = n*m*p


3   float a[2][2][3];   n = 2 , m = 2, p = 3
                             = 2*2*3 = 12
Column 0                         Column 1

              1          2          3          1           2          3

Row 0   a[0][0][0] a[0][0][1] a[0][0][2] a[0][1][0] a[0][1][1] a[0][1][2]

Row 1   a[1][0][0] a[1][0][1] a[1][0][2] a[1][1][0] a[1][1][1] a[1][1][2]




        4 bytes                             12
                             4*12 = 48 bytes
(initializing arrays)


1)
            1(                 1

     type arrayname[size] = { value list };
2(               2
      type arrayname[n][m] = { value list };

value list

             , (comma)
                                              { }
         5.6 int a[10] = {10, 20, 30, 40,50, 60, 70,
80, 90, 100};
(table)




4 bytes
     = 4*15 = 60 bytes
2)


         1(                 1
char arrayname[size] = “string constant”;


                 2(                 2
char arrayname[n][m] = {“string constant”};


         string constants
             , (comma)
                  5.8 char s[12] = “ASIAN GAME”
;
null character
2




province [0]          1
       NAKHONPANOM
province [1]           2
       SAKON NAKHON     province [2]
      3               MOOKDAHAN
province [0][0]         province [0]   1
         N
province [1][2]        province [1]    3
         K
for   while   do while

                         for
11

25

26

27
     61
28

39

More Related Content

What's hot

7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials
hisema01
 
10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials
Bitsy Griffin
 
Module 9 Topic 1 - Adding & Subtracting polynomials
Module 9 Topic 1 - Adding & Subtracting polynomialsModule 9 Topic 1 - Adding & Subtracting polynomials
Module 9 Topic 1 - Adding & Subtracting polynomials
Lori Rapp
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
Ross Lawley
 
Factorising Common Factors
Factorising Common FactorsFactorising Common Factors
Factorising Common Factors
Passy World
 
01 derivadas
01   derivadas01   derivadas
01 derivadas
klorofila
 
1 4 homework
1 4 homework1 4 homework
1 4 homework
math123b
 
last lecture in infinite series
last lecture in infinite serieslast lecture in infinite series
last lecture in infinite series
Alaa Mohammed
 
Notes 12.1 identifying, adding & subtracting polynomials
Notes 12.1   identifying, adding & subtracting polynomialsNotes 12.1   identifying, adding & subtracting polynomials
Notes 12.1 identifying, adding & subtracting polynomials
Lori Rapp
 

What's hot (20)

7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials
 
Ejercicios algebra.
Ejercicios algebra.Ejercicios algebra.
Ejercicios algebra.
 
10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials
 
Factoring2
Factoring2Factoring2
Factoring2
 
MS2 POwer Rules
MS2 POwer RulesMS2 POwer Rules
MS2 POwer Rules
 
Module 9 Topic 1 - Adding & Subtracting polynomials
Module 9 Topic 1 - Adding & Subtracting polynomialsModule 9 Topic 1 - Adding & Subtracting polynomials
Module 9 Topic 1 - Adding & Subtracting polynomials
 
Multiplication of polynomials
Multiplication of polynomialsMultiplication of polynomials
Multiplication of polynomials
 
125 7.7
125 7.7125 7.7
125 7.7
 
Distributive property in algebra power point
Distributive property in algebra power pointDistributive property in algebra power point
Distributive property in algebra power point
 
0303 ch 3 day 3
0303 ch 3 day 30303 ch 3 day 3
0303 ch 3 day 3
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
 
0304 ch 3 day 4
0304 ch 3 day 40304 ch 3 day 4
0304 ch 3 day 4
 
Factorising Common Factors
Factorising Common FactorsFactorising Common Factors
Factorising Common Factors
 
1.funtions (1)
1.funtions (1)1.funtions (1)
1.funtions (1)
 
01 derivadas
01   derivadas01   derivadas
01 derivadas
 
1 4 homework
1 4 homework1 4 homework
1 4 homework
 
9-9 Notes
9-9 Notes9-9 Notes
9-9 Notes
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
last lecture in infinite series
last lecture in infinite serieslast lecture in infinite series
last lecture in infinite series
 
Notes 12.1 identifying, adding & subtracting polynomials
Notes 12.1   identifying, adding & subtracting polynomialsNotes 12.1   identifying, adding & subtracting polynomials
Notes 12.1 identifying, adding & subtracting polynomials
 

Similar to ตัวแปรชุดและตัวแปรกลุ่มอักขระ

รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
Areeya Onnom
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
Areeya Onnom
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
웅식 전
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 

Similar to ตัวแปรชุดและตัวแปรกลุ่มอักขระ (20)

รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
 
R
RR
R
 
Secretary_Game_With_Rejection.pdf
Secretary_Game_With_Rejection.pdfSecretary_Game_With_Rejection.pdf
Secretary_Game_With_Rejection.pdf
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
Csm chapters12
Csm chapters12Csm chapters12
Csm chapters12
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
 
Data types
Data typesData types
Data types
 
9A%20thejesvi%20math%20journal%20activity%201-7.pdf
9A%20thejesvi%20math%20journal%20activity%201-7.pdf9A%20thejesvi%20math%20journal%20activity%201-7.pdf
9A%20thejesvi%20math%20journal%20activity%201-7.pdf
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
R programming language
R programming languageR programming language
R programming language
 
Numpy発表資料
Numpy発表資料Numpy発表資料
Numpy発表資料
 

More from Jiraporn Chaijaroen

คำถามท้ายบท
คำถามท้ายบทคำถามท้ายบท
คำถามท้ายบท
Jiraporn Chaijaroen
 

More from Jiraporn Chaijaroen (12)

กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
คำถามท้ายบท
คำถามท้ายบทคำถามท้ายบท
คำถามท้ายบท
 
กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
กลุ่ม 3 method
กลุ่ม 3 methodกลุ่ม 3 method
กลุ่ม 3 method
 
นางสาวจีราพร ชัยเจริญ ข่าว It new
นางสาวจีราพร  ชัยเจริญ ข่าว It newนางสาวจีราพร  ชัยเจริญ ข่าว It new
นางสาวจีราพร ชัยเจริญ ข่าว It new
 
สรุป การพรีเซนงาน (ณัฐชยา)
สรุป การพรีเซนงาน (ณัฐชยา)สรุป การพรีเซนงาน (ณัฐชยา)
สรุป การพรีเซนงาน (ณัฐชยา)
 
น้ำ
น้ำน้ำ
น้ำ
 
สรุปการพรีเซนกลุ่ม 5
สรุปการพรีเซนกลุ่ม 5 สรุปการพรีเซนกลุ่ม 5
สรุปการพรีเซนกลุ่ม 5
 
สรุปการพรีเซน
สรุปการพรีเซนสรุปการพรีเซน
สรุปการพรีเซน
 

ตัวแปรชุดและตัวแปรกลุ่มอักขระ

  • 1.
  • 2.
  • 3. 1. 1 (One Dimensional Array) [] subscript type array-name[n]; type array-name n
  • 4. char number[5]; int time[3]; float interest[2]; number, time interest subscript scanf(“%d”,&time[1]); printf(“%fn”,interest[0]); 2( time[1]) time 1( interest[0]) interest
  • 5. char number[5]; 5x1 = 5 char 5 number[0], number[1], number[2], number[3] number[4] number 1000
  • 6.
  • 7. int time[3]; 3x2 = 6 int 3 time[0], time[1] time[2] time 2000 time[0] 2000+(0x2) = 2000 time[1] 2000+(1x2) = 2002 time[2] 2000+(2x2) = 2004
  • 8. float interest[2]; 2x4 = 8 float 2 interest[0] interest[1] interest 3000 interest[0] 3000+(0x4) = 3000 interest[1] 3000+(1x4) = 3004
  • 9. 2. 2 (Two Dimensional Array) []2 Matrix 2
  • 11. int score[3][2]; 3x2 = 6 score score[0][0] score[0][1] score[1][0] score[1][1] score[2][0] score[2][1] char person[10][5][80]; int incomes[3][5][2]; float marks[2][4][20];
  • 12. 3. (Array Initialization) declare 1 char msg1[ ] = “Give value for x”; int x1[ ] = {10,2,8}; float y1[ ] = {12.8,11.3,9.2,6.35};
  • 13. 2 char msg2[ ][40] = {{“SOONTORN”}, “BANGKOK”}, {“AMORN”}, {“CHONBURI”}, {“PRAPAI”}, {“KHONKAEN”}}; int x2[ ][3] = {{10,2,8},{5,15,7}}; float y2[ ][4] = {12.8,11.3,9.2,6.35, 2.28,31.3,19.2,86.5, 12.0,17.43,7.12,62.3};
  • 14. 2 1 1 5 #include<stdio.h> void main( ) { int room_no[ ] = {22, 18, 20, 24, 21}; int total = 0, n = 0; do { total = total + room_no[n]; printf(“Room %d has %3d pupilsn”,n+1,room_no[n]); n++; } while(n<5); printf(“ = = = n”); printf(“Total no is %3d pupilsn”,total);
  • 15. (arrays) (string)
  • 16. 1) 100 100 int k1, k2, k3, …, k100; /* k1, k2, k3, …, k100 100 */ 100 subscript int k[100]; /* 1 k */ 2) (table) 2 3)
  • 17. 1 (arrays variables) (subscript)
  • 18. 1.1 1) 1 (one dimension arrays single dimension arrays) 1 (subscript) 1 a[20], b[100], name[30] salary[20]
  • 19. 2) (multi- dimension arrays) (subscript) 2 2 3 - 2 (two dimension arrays) (subscript) 2 a[2][4], b[3][4], name[5][30] - 3 (three dimension arrays) (subscript) 3 a[2][3][4], b[3][4][5]
  • 20. 2 (declaration of arrays) 1) 1 (declaration of one dimension arrays) type int, float, char, double arrayname size
  • 21. 1 5.1 int s[20]; 2 bytes 20 40 bytes
  • 22. 5.2 char p[20]; 1 bytes 20 20 bytes
  • 23. 5.3 float t[20]; 4 bytes 20 80 bytes
  • 24. 2) 2 (declaration of two dimension arrays) type int, float, char, double arrayname n row) 0, 1, 2, …, n-1 m column)
  • 25. 2 int r[3][2]; 2 (table) n = 0, 1, 2 m = 0, 1 2 bytes 6
  • 26. 1 2 1 = (size) 2 = n*m int r[3] [2]; n = 3, m = 2 = 3*2 = 6 r[0][0], r[0][1], r[n-1][m-1] 6
  • 27. 3) 3 (declaration of three dimension arrays) type arrayname [n] [m] [p]; type int, float, char, double arrayname n 1 0, 1, 2, …., n-1 m 2 0, 1, 2, …., m- 1 p 3 0, 1, 2, …., p-1
  • 28. 3 = n*m*p 3 float a[2][2][3]; n = 2 , m = 2, p = 3 = 2*2*3 = 12
  • 29. Column 0 Column 1 1 2 3 1 2 3 Row 0 a[0][0][0] a[0][0][1] a[0][0][2] a[0][1][0] a[0][1][1] a[0][1][2] Row 1 a[1][0][0] a[1][0][1] a[1][0][2] a[1][1][0] a[1][1][1] a[1][1][2] 4 bytes 12 4*12 = 48 bytes
  • 30. (initializing arrays) 1) 1( 1 type arrayname[size] = { value list };
  • 31. 2( 2 type arrayname[n][m] = { value list }; value list , (comma) { } 5.6 int a[10] = {10, 20, 30, 40,50, 60, 70, 80, 90, 100};
  • 32. (table) 4 bytes = 4*15 = 60 bytes
  • 33. 2) 1( 1 char arrayname[size] = “string constant”; 2( 2 char arrayname[n][m] = {“string constant”}; string constants , (comma) 5.8 char s[12] = “ASIAN GAME” ;
  • 35. 2 province [0] 1 NAKHONPANOM province [1] 2 SAKON NAKHON province [2] 3 MOOKDAHAN province [0][0] province [0] 1 N province [1][2] province [1] 3 K
  • 36. for while do while for
  • 37. 11 25 26 27 61 28 39