SlideShare a Scribd company logo
1 of 2
one & two dimensional arrays CLASS ACTVITY SELF TEST
LOOP:
You can use it for one-dimensional array, for either row or
column.
Dim a(2) AS Integer
Use loop to initialize all
locations to zero (0)
– Declare 2 dimensional integer array but not initialized:
Dim a(,) As Integer
– Declare 3 dimensional integer array but not initialized:
Dim b(,,) As Integer
– In the following example you need to perform two steps
to create an array declare and Initialize.
– Declare and initialize two-dimensional integer array
Dim c(2,1) As Integer
c(0,0) = 33
c(0,1) = 71
c(1,0) = -16
c(1,1) = 45
c(2,0) = 99
c(2,1) = -27
In two-dimensional array, you can use the following
command to get the length of row and column.
For rows c.GetUpperBound(0)
For columns c.GetUpperBound(1)
NESTED LOOP (loop within a loop)
You can use it for two-dimensional array. In Visual Basic,
you can declare arrays with up to 32 dimensions.
The following statement declares a two-dimensional array
of 3 rows and 3 columns.
Dim a(2,2) As Integer
1st loop for row,
2nd loop for column
For row = 0 to 2
For col = 0 to 2
0 1 2
0
1
2
Q1: Initialize with "0" the two-dim array using nested loop
Q2: Fill the two-dimensional array using nested loop
0 1 2
0 0 1 1
1 1 0 1
2 1 1 0
Q3: Fill the two-dimensional array with the following
pattern using nested loop
0 1 2
0 1 1 0
1 1 0 1
2 0 1 1
Try yourself Homework ( ‫م‬‫س‬‫ق‬‫آ‬, NO COPY)
Q4: Write a code to count the total number of even
and odd elements in an array {8, 9, 22, 25, 26}
0
1
2
0 1 2
one & two dimensional arrays CLASS ACTVITY SELF TEST
Q5: write a program to add 2 one-dimensional
arrays.
{8,7,3,5} + {1,2,7,10} = {9,9,10,15}
Q6: write a program to find sum of each row of a
matrix (Hint: use nested loop)
10 15 20 45
15 20 30 = 65
20 10 40 70
Q7: write a program to print the sum of the
following matrix (Hint: use nested loop)
Q8: Write a program to copy all elements from an
array to another array.
Q9: Write a program to put even and odd elements
of array in two separate array.
Q10: Write a program to find sum of each row and
column of a matrix.
Q11: Write a program that asks the user to type 10
integers of an array. The program must compute
and write how many integers are greater than or
equal to 10.
Q12: Challenge: Write a program to multiply the
following 2 matrices (Hint: use 3 nested loop)
Input
Processing
Output
1 2
3 4
4 3
5 6
1x4 +2x5 1x3 +2x6
3x4 +4x5 3x3 +4x6
14 15
32 33
4 5 6
7 4 1
6 5 3
=+
x ==
1 1 1
2 2 2
3 3 3
5 6 7
9 6 3
9 8 6

More Related Content

What's hot

CS106 Lab 10 - Functions (passing by value)
CS106 Lab 10 - Functions (passing by value)CS106 Lab 10 - Functions (passing by value)
CS106 Lab 10 - Functions (passing by value)Nada Kamel
 
Python decision making_loops_control statements part9
Python decision making_loops_control statements part9Python decision making_loops_control statements part9
Python decision making_loops_control statements part9Vishal Dutt
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your networkPushpendra Tiwari
 
Alg March 26, 2009
Alg March 26, 2009Alg March 26, 2009
Alg March 26, 2009Mr. Smith
 
Ds list of experiments ce
Ds list of experiments ceDs list of experiments ce
Ds list of experiments ceShraddha Patel
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...AAKASH KUMAR
 
Itroroduction to R language
Itroroduction to R languageItroroduction to R language
Itroroduction to R languagechhabria-nitesh
 
CS106 Lab 11 - Functions (passing by reference)
CS106 Lab 11 - Functions (passing by reference)CS106 Lab 11 - Functions (passing by reference)
CS106 Lab 11 - Functions (passing by reference)Nada Kamel
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeData Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeRsquared Academy
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming languageAulia Khalqillah
 

What's hot (19)

Team 6
Team 6Team 6
Team 6
 
WAP to add two given matrices in Java
WAP to add two given matrices in JavaWAP to add two given matrices in Java
WAP to add two given matrices in Java
 
CS106 Lab 10 - Functions (passing by value)
CS106 Lab 10 - Functions (passing by value)CS106 Lab 10 - Functions (passing by value)
CS106 Lab 10 - Functions (passing by value)
 
Python decision making_loops_control statements part9
Python decision making_loops_control statements part9Python decision making_loops_control statements part9
Python decision making_loops_control statements part9
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
 
Alg March 26, 2009
Alg March 26, 2009Alg March 26, 2009
Alg March 26, 2009
 
Matlab lab exe
Matlab lab exeMatlab lab exe
Matlab lab exe
 
Merge sort
Merge sortMerge sort
Merge sort
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Ds list of experiments ce
Ds list of experiments ceDs list of experiments ce
Ds list of experiments ce
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
Itroroduction to R language
Itroroduction to R languageItroroduction to R language
Itroroduction to R language
 
GNU octave
GNU octaveGNU octave
GNU octave
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
CS106 Lab 11 - Functions (passing by reference)
CS106 Lab 11 - Functions (passing by reference)CS106 Lab 11 - Functions (passing by reference)
CS106 Lab 11 - Functions (passing by reference)
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeData Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
 

Similar to two dimensional array

C programming session 05
C programming session 05C programming session 05
C programming session 05Vivek Singh
 
Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]Palak Sanghani
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptadityavarte
 
Array,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN CArray,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN Cnaveed jamali
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injavairdginfo
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 
Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-stringsPrincess Sam
 
Java programming lab assignments
Java programming lab assignments Java programming lab assignments
Java programming lab assignments rajni kaushal
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxanhlodge
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 
Mcq 15-20Q15Which of the following trees are binary search tr
Mcq 15-20Q15Which of the following trees are binary search trMcq 15-20Q15Which of the following trees are binary search tr
Mcq 15-20Q15Which of the following trees are binary search trAbramMartino96
 
Octave - Prototyping Machine Learning Algorithms
Octave - Prototyping Machine Learning AlgorithmsOctave - Prototyping Machine Learning Algorithms
Octave - Prototyping Machine Learning AlgorithmsCraig Trim
 

Similar to two dimensional array (20)

Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
JavaProgrammingManual
JavaProgrammingManualJavaProgrammingManual
JavaProgrammingManual
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]Lec 8 03_sept [compatibility mode]
Lec 8 03_sept [compatibility mode]
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.ppt
 
Array,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN CArray,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN C
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Lesson 18-20.pptx
Lesson 18-20.pptxLesson 18-20.pptx
Lesson 18-20.pptx
 
Java assgnmt2.
Java assgnmt2.Java assgnmt2.
Java assgnmt2.
 
Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-strings
 
C Arrays.ppt
C Arrays.pptC Arrays.ppt
C Arrays.ppt
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Java programming lab assignments
Java programming lab assignments Java programming lab assignments
Java programming lab assignments
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 
Mcq 15-20Q15Which of the following trees are binary search tr
Mcq 15-20Q15Which of the following trees are binary search trMcq 15-20Q15Which of the following trees are binary search tr
Mcq 15-20Q15Which of the following trees are binary search tr
 
Octave - Prototyping Machine Learning Algorithms
Octave - Prototyping Machine Learning AlgorithmsOctave - Prototyping Machine Learning Algorithms
Octave - Prototyping Machine Learning Algorithms
 

More from Tariq Aziz

Database Normalization slides
Database Normalization slidesDatabase Normalization slides
Database Normalization slidesTariq Aziz
 
Object Oriented Programming - Lab Activity
Object Oriented Programming - Lab ActivityObject Oriented Programming - Lab Activity
Object Oriented Programming - Lab ActivityTariq Aziz
 
Object Oriented Programming - Classes and Library
Object Oriented Programming - Classes and LibraryObject Oriented Programming - Classes and Library
Object Oriented Programming - Classes and LibraryTariq Aziz
 
30 hadeeth-for-children
30 hadeeth-for-children30 hadeeth-for-children
30 hadeeth-for-childrenTariq Aziz
 
Sap hana interactive_education_shine_en (1)
Sap hana interactive_education_shine_en (1)Sap hana interactive_education_shine_en (1)
Sap hana interactive_education_shine_en (1)Tariq Aziz
 

More from Tariq Aziz (7)

Mazeed feeh
Mazeed feehMazeed feeh
Mazeed feeh
 
Database Normalization slides
Database Normalization slidesDatabase Normalization slides
Database Normalization slides
 
Object Oriented Programming - Lab Activity
Object Oriented Programming - Lab ActivityObject Oriented Programming - Lab Activity
Object Oriented Programming - Lab Activity
 
Object Oriented Programming - Classes and Library
Object Oriented Programming - Classes and LibraryObject Oriented Programming - Classes and Library
Object Oriented Programming - Classes and Library
 
Nahw course 5
Nahw course 5Nahw course 5
Nahw course 5
 
30 hadeeth-for-children
30 hadeeth-for-children30 hadeeth-for-children
30 hadeeth-for-children
 
Sap hana interactive_education_shine_en (1)
Sap hana interactive_education_shine_en (1)Sap hana interactive_education_shine_en (1)
Sap hana interactive_education_shine_en (1)
 

Recently uploaded

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

two dimensional array

  • 1. one & two dimensional arrays CLASS ACTVITY SELF TEST LOOP: You can use it for one-dimensional array, for either row or column. Dim a(2) AS Integer Use loop to initialize all locations to zero (0) – Declare 2 dimensional integer array but not initialized: Dim a(,) As Integer – Declare 3 dimensional integer array but not initialized: Dim b(,,) As Integer – In the following example you need to perform two steps to create an array declare and Initialize. – Declare and initialize two-dimensional integer array Dim c(2,1) As Integer c(0,0) = 33 c(0,1) = 71 c(1,0) = -16 c(1,1) = 45 c(2,0) = 99 c(2,1) = -27 In two-dimensional array, you can use the following command to get the length of row and column. For rows c.GetUpperBound(0) For columns c.GetUpperBound(1) NESTED LOOP (loop within a loop) You can use it for two-dimensional array. In Visual Basic, you can declare arrays with up to 32 dimensions. The following statement declares a two-dimensional array of 3 rows and 3 columns. Dim a(2,2) As Integer 1st loop for row, 2nd loop for column For row = 0 to 2 For col = 0 to 2 0 1 2 0 1 2 Q1: Initialize with "0" the two-dim array using nested loop Q2: Fill the two-dimensional array using nested loop 0 1 2 0 0 1 1 1 1 0 1 2 1 1 0 Q3: Fill the two-dimensional array with the following pattern using nested loop 0 1 2 0 1 1 0 1 1 0 1 2 0 1 1 Try yourself Homework ( ‫م‬‫س‬‫ق‬‫آ‬, NO COPY) Q4: Write a code to count the total number of even and odd elements in an array {8, 9, 22, 25, 26} 0 1 2 0 1 2
  • 2. one & two dimensional arrays CLASS ACTVITY SELF TEST Q5: write a program to add 2 one-dimensional arrays. {8,7,3,5} + {1,2,7,10} = {9,9,10,15} Q6: write a program to find sum of each row of a matrix (Hint: use nested loop) 10 15 20 45 15 20 30 = 65 20 10 40 70 Q7: write a program to print the sum of the following matrix (Hint: use nested loop) Q8: Write a program to copy all elements from an array to another array. Q9: Write a program to put even and odd elements of array in two separate array. Q10: Write a program to find sum of each row and column of a matrix. Q11: Write a program that asks the user to type 10 integers of an array. The program must compute and write how many integers are greater than or equal to 10. Q12: Challenge: Write a program to multiply the following 2 matrices (Hint: use 3 nested loop) Input Processing Output 1 2 3 4 4 3 5 6 1x4 +2x5 1x3 +2x6 3x4 +4x5 3x3 +4x6 14 15 32 33 4 5 6 7 4 1 6 5 3 =+ x == 1 1 1 2 2 2 3 3 3 5 6 7 9 6 3 9 8 6