SlideShare a Scribd company logo
1 of 12
Multiple-Subscripted Arrays
• Example
• int a[3][4];
Row 0
Row 1
Row 2
Column 0 Column 1 Column 2 Column 3
a[ 0 ][ 0 ]
a[ 1 ][ 0 ]
a[ 2 ][ 0 ]
a[ 0 ][ 1 ]
a[ 1 ][ 1 ]
a[ 2 ][ 1 ]
a[ 0 ][ 2 ]
a[ 1 ][ 2 ]
a[ 2 ][ 2 ]
a[ 0 ][ 3 ]
a[ 1 ][ 3 ]
a[ 2 ][ 3 ]
Row subscript
Array name
Column subscript
Multiple-Subscripted Arrays’ Definition
type-name array-name[row-number][column-number];
• Example
int a[3][3], b[30][3];
char name[30][20];
float score[30][5];
a[3][3]
a[0] a[0][0] a[0][1] a[0][2]
a[1] a[1][0] a[1][1] a[1][2]
a[2] a[2][0] a[2][1] a[2][2]
Multiple-Subscripted Arrays’ Storage
• Example
• int a[2][3];
a[0][0] a[0][1] a[0][2]
a[1][0] a[1][1] a[1][2]
12
32
-1
87
0
53
a[0][0]
a[0][1]
a[0][2]
a[1][0]
a[1][1]
a[1][2]
a
Multiple-Subscripted Arrays’ Initialization
int a[2][3]={{10,11,12},{13,14,15}};
int a[2][3]={10,11,12,13,14,15};
a[0][0] a[0][1] a[0][2]
10 11 12
a[1][0] a[1][1] a[1][2]
13 14 15
Multiple-Subscripted Arrays’ Initialization
int a[2][3]={{10,11},{13}};
a[0][0] a[0][1] a[0][2]
10 11 0
a[1][0] a[1][1] a[1][2]
13 0 0
int a[2][3]={10,11,13};
a[0][0] a[0][1] a[0][2]
10 11 13
a[1][0] a[1][1] a[1][2]
0 0 0
Multiple-Subscripted Arrays’ Initialization
int a[ ][3]={{10,11,12},{13,14,15}};
int a[ ][3]={10,11,12,13,14,15};
a[0][0] a[0][1] a[0][2]
10 11 12
a[1][0] a[1][1] a[1][2]
13 14 15
Multiple-Subscripted Arrays’ Initialization
int a[ ][3]={{10,11},{13}};
a[0][0] a[0][1] a[0][2]
10 11 0
a[1][0] a[1][1] a[1][2]
13 0 0
Examples: Multiple-Subscripted Arrays
Example: Multiple-Subscripted Arrays







6
5
4
3
2
1
a











6
3
5
2
4
1
b
for(i=0;i<3;i++)
for(j=0;j<2;j++)
b[i][j] = a[j][i]
Examples: Multiple-Subscripted Arrays
Example: Multiple-Subscripted Arrays
#include <stdio.h>
void main() {
int a[2][3]={1,2,3,4,5,6}, b[3][2];
int i, j;
printf("matrix a is:n");
for (i=0; i<2; i++) {
for (j=0; j<3; j++) {
b[j][i] = a[i][j];
printf("%3d", a[i][j]);
}
printf("n");
}
Examples: Multiple-Subscripted Arrays
Example: Multiple-Subscripted Arrays
printf("matrix b is:n");
for (i=0; i<3; i++) {
for (j=0; j<2; j++)
printf("%3d", b[i][j]);
printf("n");
}
}
matrix a is:
1 2 3
4 5 6
matrix b is:
1 4
2 5
3 6
Examples: Multiple-Subscripted Arrays
Example: Multiple-Subscripted Arrays










3
5
7
9
6
8
5
7
4
3
2
1
Examples: Multiple-Subscripted Arrays
Example: Multiple-Subscripted Arrays
……
for (i=0; i<3; i++)
for (j=3; j>0; j--)
if (num[i][j]>num[i][j-1]) {
tmp = num[i][j];
num[i][j] = num[i][j-1];
num[i][j-1] = tmp;
}
……

More Related Content

Similar to Session09 multi dimarrays

ตัวแปรชุดและตัวแปรกลุ่มอักขระ
ตัวแปรชุดและตัวแปรกลุ่มอักขระตัวแปรชุดและตัวแปรกลุ่มอักขระ
ตัวแปรชุดและตัวแปรกลุ่มอักขระJiraporn Chaijaroen
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptxSKUP1
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptxLECO9
 
Week 10 - Lecture 27 - 3D Arrays.pptx
Week 10 - Lecture 27 - 3D Arrays.pptxWeek 10 - Lecture 27 - 3D Arrays.pptx
Week 10 - Lecture 27 - 3D Arrays.pptxDOHAaqeel
 
Array , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxArray , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxMrNikhilMohanShinde
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming2569294Mohan
 
Array Data Structures
Array Data StructuresArray Data Structures
Array Data StructuresSoni Gupta
 

Similar to Session09 multi dimarrays (8)

ตัวแปรชุดและตัวแปรกลุ่มอักขระ
ตัวแปรชุดและตัวแปรกลุ่มอักขระตัวแปรชุดและตัวแปรกลุ่มอักขระ
ตัวแปรชุดและตัวแปรกลุ่มอักขระ
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
Week 10 - Lecture 27 - 3D Arrays.pptx
Week 10 - Lecture 27 - 3D Arrays.pptxWeek 10 - Lecture 27 - 3D Arrays.pptx
Week 10 - Lecture 27 - 3D Arrays.pptx
 
Array , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxArray , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptx
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array Data Structures
Array Data StructuresArray Data Structures
Array Data Structures
 

More from HarithaRanasinghe (20)

Session12 pointers
Session12 pointersSession12 pointers
Session12 pointers
 
Session11 single dimarrays
Session11 single dimarraysSession11 single dimarrays
Session11 single dimarrays
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Session06 functions
Session06 functionsSession06 functions
Session06 functions
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
Session04 selection structure_b
Session04 selection structure_bSession04 selection structure_b
Session04 selection structure_b
 
Session04 selection structure_a
Session04 selection structure_aSession04 selection structure_a
Session04 selection structure_a
 
Session03 operators
Session03 operatorsSession03 operators
Session03 operators
 
Session02 c intro
Session02 c introSession02 c intro
Session02 c intro
 
Session01 basics programming
Session01 basics programmingSession01 basics programming
Session01 basics programming
 
Program flow charts
Program flow chartsProgram flow charts
Program flow charts
 
Sad -sample_paper
Sad  -sample_paperSad  -sample_paper
Sad -sample_paper
 
Sad sample paper - mcq answers
Sad   sample paper - mcq answersSad   sample paper - mcq answers
Sad sample paper - mcq answers
 
Paper
PaperPaper
Paper
 
Model questions
Model questionsModel questions
Model questions
 
Model paper algorithms and data structures
Model paper  algorithms and data structuresModel paper  algorithms and data structures
Model paper algorithms and data structures
 
Doc 20180208-wa0001
Doc 20180208-wa0001Doc 20180208-wa0001
Doc 20180208-wa0001
 
Doc 20180130-wa0006
Doc 20180130-wa0006Doc 20180130-wa0006
Doc 20180130-wa0006
 
Doc 20180130-wa0005
Doc 20180130-wa0005Doc 20180130-wa0005
Doc 20180130-wa0005
 
Doc 20180130-wa0004-1
Doc 20180130-wa0004-1Doc 20180130-wa0004-1
Doc 20180130-wa0004-1
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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 educationjfdjdjcjdnsjd
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Session09 multi dimarrays