SlideShare a Scribd company logo
1 of 20
2 DIMENSIONAL
ARRAY
GROUP A ‘EVEREST’
Amit Budachhetri
Anil Pokhrel
Ajit Pudasaini
Rikriti Koirala
Roji shrestha
Puja Neupane 1
CONTENTS
• Basic array
• Difference between 1D &2D
• 2 Dimension Array
• Syntax of 2 D
• Processing Two-Dimensional Arrays
• Declaration of 2 D
• Examples of 2D
• Conclusion
2
Array
• Consecutive group of memory location
• All of which have the same type
• We have 1D,2D 3D types of array
• Position number used to refer to a specific
location/element
• Place in square brackets
• Must be positive integer or integer expression
• First element has index zero
3
Difference between 1D &2D
• 1d array contains single row and multiple
columns
• 2d array contains multiple row and multiple
columns
• 2d array is a collection of 1d array placed one
below
• 1d has only the length, but 2d has both the
length and width
4
5
2D Array
• Two-dimensional Array: a collection of a fixed
number of components arranged in two dimensions
• All components are of the same type
• The two expressions row size and column size specify
the number of rows and the number of columns,
respectively, in the array
• Two-dimensional arrays are sometimes called
matrices or tables
6
Syntax
• The syntax for declaring a two-dimensional
array is:
Data Type Array Name[rowsize][columnsize];
where row size and column size are
expressions yielding positive integer values
Example:int data[3][4];
―Data is a TWO Dimensional array of size 3*4
elements
7
Lets observe the table:
8
Processing Two-Dimensional Arrays:
• A two-dimensional array can be processed in
three different ways:
1. Process the entire array
2. Process a particular row of the array, called row
processing
3. Process a particular column of the array, called
column processing
9
Declaration
• A 2-D array within a function is declared as
follows:
• #define ROW 3
• define COL 5
• ..... what(....)
• {
• int a[ROW][COL] .... ;
• ..........................
• }
10
11
1.Program to transpose a matrix.
#include <stdio.h>
#define MAXROW 10
#define MAXCOL 10
int main()
{
int matrix[MAXROW][MAXCOL];
int i,j,r,c;
printf("Enter number of Rows :");
scanf("%d",&r);
printf("Enter number of Cols :");
scanf("%d",&c);
printf("nEnter matrix elements :n");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++) 12
{
printf("Enter element [%d,%d] : ",i+1,j+1);
scanf("%d",&matrix[i][j]);
}
}
/*Transpose a matrix */
printf("nTranspose Matrix is :");
for(i=0;i< c;i++)
{
for(j=0;j< r;j++) {
printf("%dt",matrix[j][i]); /*print elements*/
}
printf("n"); /*after each row print new line*/
}
return 0;
} 13
OUTPUT
• Enter number of Rows :2
• Enter number of Cols :3
• Enter matrix elements :
• Enter element [1,1] : 1
• Enter element [1,2] : 2
• Enter element [1,3] : 3
• Enter element [2,1] : 4
• Enter element [2,2] : 5
• Enter element [2,3] : 6
• Transpose Matrix is : 1 4
2 5
3 6 14
2.Program to find multiplication table
• #include<stdio.h>
• #define R5
• #define C5 void main()
• {
• int R, C, product[R][C]; int i, j;
printf("multiplication tablenn");
• Printf(“ “)
• for(j=1; j<=C; j++)
• {
• printf("%4d",j);
• printf("n"); 15
• printf("__________________________");
• }
• for(i=0; i<R; i++)
• {
• R=i+1;
• printf("%2d",R);
• for(j=1; j<=C; j++)
• {
• C=j;
• product[i][j]=R*C;
• printf("%4d",product[i][j]);
• }
• printf("n");
• } 16
OUTPUT
17
Conclusion
• Two-dimensional array are those type of array, which
has finite number of rows and finite number of
columns
• The rule for giving the array name is same as the
ordinary variable
• The row size and column size should be an individual
constant.
• during declaration the maximum number of rows
and maximum number of column should be specified
for processing all array elements 18
Reference
• Google.com
• E.Balaguruswamy- Programming in ANSI
• Teacher’s notes (MR.LOK PRAKASH
PANDEY)
19
20

More Related Content

What's hot

Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-stringsPrincess Sam
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayimtiazalijoono
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional arrayRajendran
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy AminaRepo
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in CSmit Parikh
 
Sql 99 and_some_techniques
Sql 99 and_some_techniquesSql 99 and_some_techniques
Sql 99 and_some_techniquesAlexey Kiselyov
 
Refinement Types for Haskell
Refinement Types for HaskellRefinement Types for Haskell
Refinement Types for HaskellMartin Ockajak
 
Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>Svetlin Nakov
 
Comparing Haskell & Scala
Comparing Haskell & ScalaComparing Haskell & Scala
Comparing Haskell & ScalaMartin Ockajak
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java DevelopersMartin Ockajak
 

What's hot (20)

1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
2D Array
2D Array 2D Array
2D Array
 
Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-strings
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional array
 
Array lecture
Array lectureArray lecture
Array lecture
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream APIJava Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Java arrays
Java arraysJava arrays
Java arrays
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Arrays
ArraysArrays
Arrays
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Sql 99 and_some_techniques
Sql 99 and_some_techniquesSql 99 and_some_techniques
Sql 99 and_some_techniques
 
Refinement Types for Haskell
Refinement Types for HaskellRefinement Types for Haskell
Refinement Types for Haskell
 
Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>
 
Comparing Haskell & Scala
Comparing Haskell & ScalaComparing Haskell & Scala
Comparing Haskell & Scala
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 

Similar to 2D ARRAY TUTORIAL

C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxrohinitalekar1
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxJumanneChiyanda
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptxchin463670
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...AntareepMajumder
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...nsitlokeshjain
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp fullVõ Hòa
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data StructureMandeep Singh
 
Basics of Python
Basics of PythonBasics of Python
Basics of PythonEase3
 
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
 
R_CheatSheet.pdf
R_CheatSheet.pdfR_CheatSheet.pdf
R_CheatSheet.pdfMariappanR3
 

Similar to 2D ARRAY TUTORIAL (20)

Arrays 06.ppt
Arrays 06.pptArrays 06.ppt
Arrays 06.ppt
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
ReviewArrays.ppt
ReviewArrays.pptReviewArrays.ppt
ReviewArrays.ppt
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 
Session 4
Session 4Session 4
Session 4
 
C
CC
C
 
Array i imp
Array  i impArray  i imp
Array i imp
 
About Array
About ArrayAbout Array
About Array
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
 
Basics of Python
Basics of PythonBasics of Python
Basics of Python
 
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
 
2D arrays
2D arrays2D arrays
2D arrays
 
R_CheatSheet.pdf
R_CheatSheet.pdfR_CheatSheet.pdf
R_CheatSheet.pdf
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 

More from Anil Pokhrel

Internet and intranet
Internet and intranetInternet and intranet
Internet and intranetAnil Pokhrel
 
Measure of dispersion
Measure of dispersionMeasure of dispersion
Measure of dispersionAnil Pokhrel
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regressionAnil Pokhrel
 
Correlation analysis
Correlation analysis Correlation analysis
Correlation analysis Anil Pokhrel
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
Priority scheuling
Priority scheuling Priority scheuling
Priority scheuling Anil Pokhrel
 
Operating system file system
Operating system file systemOperating system file system
Operating system file systemAnil Pokhrel
 
object oriented programming OOP
object oriented programming OOPobject oriented programming OOP
object oriented programming OOPAnil Pokhrel
 
Numerical method runge kutta method
Numerical method runge kutta methodNumerical method runge kutta method
Numerical method runge kutta methodAnil Pokhrel
 
Management profile ppt
Management profile pptManagement profile ppt
Management profile pptAnil Pokhrel
 
Bus and memory transfer
Bus and memory transferBus and memory transfer
Bus and memory transferAnil Pokhrel
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representationAnil Pokhrel
 
Management and leadership skills
Management and leadership skillsManagement and leadership skills
Management and leadership skillsAnil Pokhrel
 
color detection using open cv
color detection using open cvcolor detection using open cv
color detection using open cvAnil Pokhrel
 
Client-server technology in web design
Client-server technology in web designClient-server technology in web design
Client-server technology in web designAnil Pokhrel
 
Software Engineering requirements
Software Engineering requirementsSoftware Engineering requirements
Software Engineering requirementsAnil Pokhrel
 
I WAY (SUPER HIGHWAY INFORMATION)
I WAY (SUPER HIGHWAY INFORMATION)I WAY (SUPER HIGHWAY INFORMATION)
I WAY (SUPER HIGHWAY INFORMATION)Anil Pokhrel
 

More from Anil Pokhrel (20)

System software
System softwareSystem software
System software
 
Internet and intranet
Internet and intranetInternet and intranet
Internet and intranet
 
Measure of dispersion
Measure of dispersionMeasure of dispersion
Measure of dispersion
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regression
 
Correlation analysis
Correlation analysis Correlation analysis
Correlation analysis
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
Priority scheuling
Priority scheuling Priority scheuling
Priority scheuling
 
Operating system file system
Operating system file systemOperating system file system
Operating system file system
 
object oriented programming OOP
object oriented programming OOPobject oriented programming OOP
object oriented programming OOP
 
Numerical method runge kutta method
Numerical method runge kutta methodNumerical method runge kutta method
Numerical method runge kutta method
 
Management profile ppt
Management profile pptManagement profile ppt
Management profile ppt
 
Impact of error
Impact of errorImpact of error
Impact of error
 
Control statement
Control statementControl statement
Control statement
 
Bus and memory transfer
Bus and memory transferBus and memory transfer
Bus and memory transfer
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
 
Management and leadership skills
Management and leadership skillsManagement and leadership skills
Management and leadership skills
 
color detection using open cv
color detection using open cvcolor detection using open cv
color detection using open cv
 
Client-server technology in web design
Client-server technology in web designClient-server technology in web design
Client-server technology in web design
 
Software Engineering requirements
Software Engineering requirementsSoftware Engineering requirements
Software Engineering requirements
 
I WAY (SUPER HIGHWAY INFORMATION)
I WAY (SUPER HIGHWAY INFORMATION)I WAY (SUPER HIGHWAY INFORMATION)
I WAY (SUPER HIGHWAY INFORMATION)
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

2D ARRAY TUTORIAL

  • 1. 2 DIMENSIONAL ARRAY GROUP A ‘EVEREST’ Amit Budachhetri Anil Pokhrel Ajit Pudasaini Rikriti Koirala Roji shrestha Puja Neupane 1
  • 2. CONTENTS • Basic array • Difference between 1D &2D • 2 Dimension Array • Syntax of 2 D • Processing Two-Dimensional Arrays • Declaration of 2 D • Examples of 2D • Conclusion 2
  • 3. Array • Consecutive group of memory location • All of which have the same type • We have 1D,2D 3D types of array • Position number used to refer to a specific location/element • Place in square brackets • Must be positive integer or integer expression • First element has index zero 3
  • 4. Difference between 1D &2D • 1d array contains single row and multiple columns • 2d array contains multiple row and multiple columns • 2d array is a collection of 1d array placed one below • 1d has only the length, but 2d has both the length and width 4
  • 5. 5
  • 6. 2D Array • Two-dimensional Array: a collection of a fixed number of components arranged in two dimensions • All components are of the same type • The two expressions row size and column size specify the number of rows and the number of columns, respectively, in the array • Two-dimensional arrays are sometimes called matrices or tables 6
  • 7. Syntax • The syntax for declaring a two-dimensional array is: Data Type Array Name[rowsize][columnsize]; where row size and column size are expressions yielding positive integer values Example:int data[3][4]; ―Data is a TWO Dimensional array of size 3*4 elements 7
  • 8. Lets observe the table: 8
  • 9. Processing Two-Dimensional Arrays: • A two-dimensional array can be processed in three different ways: 1. Process the entire array 2. Process a particular row of the array, called row processing 3. Process a particular column of the array, called column processing 9
  • 10. Declaration • A 2-D array within a function is declared as follows: • #define ROW 3 • define COL 5 • ..... what(....) • { • int a[ROW][COL] .... ; • .......................... • } 10
  • 11. 11
  • 12. 1.Program to transpose a matrix. #include <stdio.h> #define MAXROW 10 #define MAXCOL 10 int main() { int matrix[MAXROW][MAXCOL]; int i,j,r,c; printf("Enter number of Rows :"); scanf("%d",&r); printf("Enter number of Cols :"); scanf("%d",&c); printf("nEnter matrix elements :n"); for(i=0;i< r;i++) { for(j=0;j< c;j++) 12
  • 13. { printf("Enter element [%d,%d] : ",i+1,j+1); scanf("%d",&matrix[i][j]); } } /*Transpose a matrix */ printf("nTranspose Matrix is :"); for(i=0;i< c;i++) { for(j=0;j< r;j++) { printf("%dt",matrix[j][i]); /*print elements*/ } printf("n"); /*after each row print new line*/ } return 0; } 13
  • 14. OUTPUT • Enter number of Rows :2 • Enter number of Cols :3 • Enter matrix elements : • Enter element [1,1] : 1 • Enter element [1,2] : 2 • Enter element [1,3] : 3 • Enter element [2,1] : 4 • Enter element [2,2] : 5 • Enter element [2,3] : 6 • Transpose Matrix is : 1 4 2 5 3 6 14
  • 15. 2.Program to find multiplication table • #include<stdio.h> • #define R5 • #define C5 void main() • { • int R, C, product[R][C]; int i, j; printf("multiplication tablenn"); • Printf(“ “) • for(j=1; j<=C; j++) • { • printf("%4d",j); • printf("n"); 15
  • 16. • printf("__________________________"); • } • for(i=0; i<R; i++) • { • R=i+1; • printf("%2d",R); • for(j=1; j<=C; j++) • { • C=j; • product[i][j]=R*C; • printf("%4d",product[i][j]); • } • printf("n"); • } 16
  • 18. Conclusion • Two-dimensional array are those type of array, which has finite number of rows and finite number of columns • The rule for giving the array name is same as the ordinary variable • The row size and column size should be an individual constant. • during declaration the maximum number of rows and maximum number of column should be specified for processing all array elements 18
  • 19. Reference • Google.com • E.Balaguruswamy- Programming in ANSI • Teacher’s notes (MR.LOK PRAKASH PANDEY) 19
  • 20. 20