SlideShare ist ein Scribd-Unternehmen logo
1 von 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], num
ber[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], na
me[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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (20)

Operations on Polynomials
Operations on PolynomialsOperations on Polynomials
Operations on Polynomials
 
125 7.7
125 7.7125 7.7
125 7.7
 
The Chain Rule Powerpoint Lesson
The Chain Rule Powerpoint LessonThe Chain Rule Powerpoint Lesson
The Chain Rule Powerpoint Lesson
 
Lesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationLesson 11: Implicit Differentiation
Lesson 11: Implicit Differentiation
 
Monads in perl
Monads in perlMonads in perl
Monads in perl
 
Ejercicios algebra.
Ejercicios algebra.Ejercicios algebra.
Ejercicios algebra.
 
Lesson 11: The Chain Rule
Lesson 11: The Chain RuleLesson 11: The Chain Rule
Lesson 11: The Chain Rule
 
Distributive property in algebra power point
Distributive property in algebra power pointDistributive property in algebra power point
Distributive property in algebra power point
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Factoring2
Factoring2Factoring2
Factoring2
 
7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials7 2 adding and subtracting polynomials
7 2 adding and subtracting polynomials
 
Chain Rule
Chain RuleChain Rule
Chain Rule
 
Chain Rule
Chain RuleChain Rule
Chain Rule
 
Solution3
Solution3Solution3
Solution3
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
1.funtions (1)
1.funtions (1)1.funtions (1)
1.funtions (1)
 
Vertex
VertexVertex
Vertex
 
Lesson 10: The Chain Rule
Lesson 10: The Chain RuleLesson 10: The Chain Rule
Lesson 10: The Chain Rule
 
10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials10 1 Adding Subtracting Polynomials
10 1 Adding Subtracting Polynomials
 
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
 

Andere mochten auch

Barsamian alexander-identifying-network-users
Barsamian alexander-identifying-network-usersBarsamian alexander-identifying-network-users
Barsamian alexander-identifying-network-users
ProQSys
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
Patrick Allaert
 
Enabling high level application development for internet of things
Enabling high level application development for internet of thingsEnabling high level application development for internet of things
Enabling high level application development for internet of things
Pankesh Patel
 
PhD Thesis Defense
PhD Thesis DefensePhD Thesis Defense
PhD Thesis Defense
Filip Krikava
 
NSA for Enterprises Log Analysis Use Cases
NSA for Enterprises   Log Analysis Use Cases NSA for Enterprises   Log Analysis Use Cases
NSA for Enterprises Log Analysis Use Cases
WSO2
 

Andere mochten auch (17)

Barsamian alexander-identifying-network-users
Barsamian alexander-identifying-network-usersBarsamian alexander-identifying-network-users
Barsamian alexander-identifying-network-users
 
80211
8021180211
80211
 
Bloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers IndiaBloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers India
 
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
 
Data & Analytics - Session 3 - Under the Covers with Amazon DynamoDB
Data & Analytics - Session 3 - Under the Covers with Amazon DynamoDBData & Analytics - Session 3 - Under the Covers with Amazon DynamoDB
Data & Analytics - Session 3 - Under the Covers with Amazon DynamoDB
 
Wireless LAN Deployment Best Practices
Wireless LAN Deployment Best PracticesWireless LAN Deployment Best Practices
Wireless LAN Deployment Best Practices
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
 
Enabling high level application development for internet of things
Enabling high level application development for internet of thingsEnabling high level application development for internet of things
Enabling high level application development for internet of things
 
Solution2(database)
Solution2(database)Solution2(database)
Solution2(database)
 
Unit i b(er model)
Unit i b(er model)Unit i b(er model)
Unit i b(er model)
 
A Modular Approach To Intrusion Detection in Homogenous Wireless Network
A Modular Approach To Intrusion Detection in Homogenous Wireless NetworkA Modular Approach To Intrusion Detection in Homogenous Wireless Network
A Modular Approach To Intrusion Detection in Homogenous Wireless Network
 
Big data streams, Internet of Things, and Complex Event Processing Improve So...
Big data streams, Internet of Things, and Complex Event Processing Improve So...Big data streams, Internet of Things, and Complex Event Processing Improve So...
Big data streams, Internet of Things, and Complex Event Processing Improve So...
 
PhD Thesis Defense
PhD Thesis DefensePhD Thesis Defense
PhD Thesis Defense
 
View, Act, and React: Shaping Business Activity with Analytics, BigData Queri...
View, Act, and React: Shaping Business Activity with Analytics, BigData Queri...View, Act, and React: Shaping Business Activity with Analytics, BigData Queri...
View, Act, and React: Shaping Business Activity with Analytics, BigData Queri...
 
WiFi Secuiry: Attack & Defence
WiFi Secuiry: Attack & DefenceWiFi Secuiry: Attack & Defence
WiFi Secuiry: Attack & Defence
 
Building Applications with DynamoDB
Building Applications with DynamoDBBuilding Applications with DynamoDB
Building Applications with DynamoDB
 
NSA for Enterprises Log Analysis Use Cases
NSA for Enterprises   Log Analysis Use Cases NSA for Enterprises   Log Analysis Use Cases
NSA for Enterprises Log Analysis Use Cases
 

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

รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
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
웅식 전
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 
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
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
Ross Lawley
 

Ähnlich wie ตัวแปรชุดและตัวแปรกลุ่มอักขระ (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
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
Data types
Data typesData types
Data types
 
Csm chapters12
Csm chapters12Csm chapters12
Csm chapters12
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
 
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
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
 
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
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
 
[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
 
2D arrays
2D arrays2D arrays
2D arrays
 
Numpy発表資料
Numpy発表資料Numpy発表資料
Numpy発表資料
 
Numpy発表資料 tokyoscipy
Numpy発表資料 tokyoscipyNumpy発表資料 tokyoscipy
Numpy発表資料 tokyoscipy
 

Mehr von Jiraporn Chaijaroen

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

Mehr von 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
 
สรุปการพรีเซน
สรุปการพรีเซนสรุปการพรีเซน
สรุปการพรีเซน
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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

  • 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], num ber[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], na me[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