0% found this document useful (0 votes)
9 views

PERT 11 - Array 2 dimensi

Uploaded by

newjnodhipati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

PERT 11 - Array 2 dimensi

Uploaded by

newjnodhipati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Algoritma

Two Dimensional A r ray

Endah Ratna Arumi, M. Cs.

Universitas M uh a mm ad iya h M ag ela ng


2024
Exercise

★ Write a simple program that asks for


the nu mb er of stu dents as i npu t.
★ The user is asked to enter the n am e,
address , major and expertise as
m u c h a s the num ber that was
previously entered.
★ Disp lay the stu dent da ta.
Exercise Advanced

★ Write a simple program that asks for


the nu mb er of stu dents as i npu t.
★ The user is asked to enter the n am e,
add ress, major, gender an d expertise
as m u c h as the nu mb er that was
previously entered.
★ Disp lay the stu dent da ta .
Exercise Advanced

★ Write a simple program that asks for the nu mb er of stu dents as


i npu t.
★ The user is asked to enter the n am e, add ress, major, gender
an d expertise as m u c h as the nu mb er that was previously
entered.
★ Disp lay the stu dent da ta .
★ Ad d choice if user want to remove data or just end the program
Two Dimensional Array

➢ A 2 D array is a n array of arrays that ca n be represented in matrix form


like rows an d colum ns. In this array, the position of data elements is
defined with two indices instead of a single index.

➢ Array_name = [rows][columns]
➢ Array_name = [ [m1, m 2 , m 3 , … . mn], [n1, n 2 , n 3 , … . . nn] ]

*Where m i s the row an d n i s the co lumn of the table


Accessing Two Dimensional Array

➢ We ca n access elements of a two-dimensional array usi ng two indic es .


The first index refers to the indexing of the list an d th e second index
refers to the position of th e elements . If we define only one index with
a n array n am e, it retur ns all the elements of 2-dimension al stored in the
array.
Create Simple Array

➢ mahasiswa = [ [82, 75, 67, 95, 70], [70, 97, 85, 79, 75], [86, 71, 80,
68,
• 93], [80, 73, 81, 94, 89], [57, 79, 86, 79, 80] ]
➢ print(mahasiswa[3]) ? ? ?
➢ print(mahasiswa[1][3]) ? ? ?
Show Output of Two Dimensional Array
Add Element to Two Dimensional Array
Change Element: Two Dimensional Array
Remove Element: Two Dimensional Array
Exercise Two Dimensional Array

★ Write a simple program that asks for


the nu mb er of stu dents as i npu t.
★ The user is asked to enter the n am e,
address , major and expertise as
m u c h a s the n um ber that was
previously entered.
★ Disp lay the stu dent da ta.
★ Use Two Dimensional Array
END

You might also like