SlideShare a Scribd company logo
Pertemuan 1 - Algoritma dan Struktur Data 1
Two Dimensional
Array
Pengertian array dua dimensi
Array dua dimensi dapat dipandang sebagai gabungan array satu dimensi
Pandanglah tiga buah array satu dimensi yang dibuat dengan int A1[5], int
A2[5], int A3[5].
Ketiga buah array satu dimensi diatas, dapat digabung menjadi satu, sehingga
terbentuk sebuah array yang disebut array dua dimensi yang biasanya
diilustrasikan sebagai berikut :
Array 1 Dimensi :
char A[5] ;
Array 2 Dimensi :
char A[3][5] ;
Isinya ada
Tapi tidak diketahui
Isinya ada
Tapi tidak diketahui
Array 1 Dimensi :
char A[5] ;
0 1 2 3
4
Array 2 Dimensi :
char A[3][5] ;
0 1 2 3
4
0
1
2
Jumlah
kolom
( column )
Jumlah kolom
Jumlah baris
( row )
Nomor
Kolom
( index )
Nomor
kolom
Nomor
baris
Array 1 Dimensi :
char A[5] ;
0 1 2 3
4
Array 2 Dimensi :
char A[3][5] ;
0 1 2 3
4
0
1
2
Jumlah kolom
Jumlah kolom
Jumlah baris
Nomor
kolom
Nomor
kolom
Nomor
baris
Isinya ada
Tapi tidak diketahui
Isinya ada
Tapi tidak diketahui
Array 2 Dimensi :
char A[3][5]
;
Sering disebut
array 3 x 5
Array 1 Dimensi :
char A[5] =
{‘A’,’B’,’C’,’D’,’E’} ;
A B C D E
0 1 2 3
4
Array 2 Dimensi :
char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’ ,
‘K’,’L’,’M’,’N’,’O } ;
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
Array
2 Dimensi
Contoh - 1
#include<stdio.h>
void main()
{ char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
baris : 1
kolom : 2
Dev C++ 5.11
Contoh - 1
#include<stdio.h>
void main()
{ char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
H
Dev C++ 5.11
Array 2 Dimensi :
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
Dev C++ 5.11
H
#include<stdio.h>
void main()
{ char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
#include<stdio.h>
void main()
{ char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
DIULANG
Apa yang tercetak ?
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
H
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[2][3] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
Apa yang tercetak ?
Kalau ini : ?
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[1][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
N
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[3][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
Apa yang tercetak ?
Kalau ini : ?
3
Apakah
Error ?
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
printf(" %c ", A[3][2] );
}
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
. Tercetak karakter
sembarang sesuai
dengan karakter
apa yang ada pada
lokasi tersebut saat itu
TIDAK
ERROR
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
char A[3][5];
A[0][0]
A[0][2]
A[1][3]
?
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
char A[3][5];
A[0][0]
A[0][2]
A[1][3]
A[2][1]
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
char A[3][5];
A[0][0]
A[0][2]
A[1][3]
A[2][1]
Pertemuan 1 - Algoritma dan Struktur Data 1
0 1 2 3
4
A B C D E
F G H I J
K L M N 0
0
1
2
char A[3][5];
i j
0 0
0 1
0 2
0 3
0 4
1 0
1 1
1 2
1 3
1 4
2 0
2 1
2 2
2 3
2 4
i
j
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
Array 2 Dimensi :
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
Logical
illustration
3 baris
5 kolom
A B C D E
0,0 0,1 0,2 0,3 0,4 1,0 1,1 1,2 1,3 1,4 2,0 2,1 2,2 2,3 2,4
F G H I J K L M N 0
memory physical allocation
secara fisik alamatnya contiguous
2,4
untuk
menyatakan
A[2][4]
Array 2 Dimensi :
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
char A[3][5] = { 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N',
'O' } ;
char A[3][5] = { 'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L',
'M', 'N', 'O' } ;
atau :
atau :
char A[3][5] = { ‘A’,’B’,’C’,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,
} ;
A B C 0 0
0 1 2 3
4
F G H I J
K L 0 0 0
0
1
2
0 (NULL)
0 0 0 0 0 0 0 0
Karakter NULL
semua bit-nya 0 (nol)
Kalau dicetak dengan ;
“ %c ” tercetak : spasi (blank
“ %i “ tercetak : 0 (nol)
“ %x “ tercetak : 00
A 0 0 0 0
0 1 2 3
4
0 0 0 0 0
0 0 0 0 0
0
1
2
char A[3][5] = { ‘A’
} ;
char A[3][5] = { 65
} ;
atau :
atau :
char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’
,
‘F’,’G’,’H’,’I’,’J’ ,
‘K’,’L’,’0’,’N’,’O’ } ;
0 1 2 3
4
A B C D E
F G H I J
K L 0 N 0
0
1
2
NULL
char A[3][5] = { "ABCDE" ,
"FGHIJ"
,
"KL
NO" } ;
0 1 2 3
4
A B C D E
F G H I J
K L N 0
0
1
2
space
space
Pertemuan 1 - Algoritma dan Struktur Data 1
0 0 0 0 0 0 0 0
Karakter NULL
Kalau dicetak dengan :
“ %c ” tercetak : spasi (blank)
“ %i “ tercetak : 0 (nol)
“ %x“ tercetak : 00
0 0 1 0 0 0 0 0
Karakter space
Kalau dicetak dengan ;
“ %c ” tercetak : spasi (blank)
“ %i “ tercetak : 32
“ %x “ tercetak : 20
Contoh - 2
Contoh - 2
#include<stdio.h>
main()
{ int A[3][5] =
{ 5,12,17,10,7,
15,6,25,2,19,
4,9,20,22,11 };
printf(" %c ", A[1][2] );
return 0;
}
0 1 2 3
4
5 12 17 10 7
15 6 25 2 19
4 9 20 22 11
0
1
2
Dev C++ 5.11
Apa yang tercetak : ?
Contoh - 2
#include<stdio.h>
void main()
{ int A[3][5] =
{ 5,12,17,10,7,
15,6,25,2,19,
4,9,20,22,11 };
printf(" %c ", A[1][2] );
}
0 1 2 3
4
5 12 17 10 7
15 6 25 2 19
4 9 20 22 11
0
1
2
Dev C++ 5.11
25
int A[3][5] =
{ 5,12,17,10,7,
15,6,25,2,19,
4,9,20,22,11 };
int A[3][5] = { 5,12,17,10,7,
15,6,25,2,19,
4,9,20,22,11 };
int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19,
4,9,20,
22,11 };
int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19,
0 1 2 3
4
5 12 17 10 7
15 6 25 2 19
4 9 20 22 11
0
1
2
atau :
atau :
atau :
int A[3][5] = { 5,12,17,10,7,
15,6,25,
2,19,4,9,
20,
22,11 };
atau :
int A[3][5] =
{ 5,12,17,10,7,
15,6,25,2,19,
4,9, } ;
0 1 2 3
4
5 12 17 10 7
15 6 25 2 19
4 9 0 0 0
0
1
2
Lokasi yang
tidak diisi,
otomatis diisi
dengan 0 (nol)
Hanya diisi
12 elemen
3 elemen
terakhir
tidak diisi
int A[3][5] =
{ 5,12,17,10,7,
15,6,25,2,19,
4,9, } ;
0 1 2 3
4
5 12 17 10 7
15 6 25 2 19
4 9 0 0 0
0
1
2
int A[3][5] = { 1, 2, 3, 4, 5,
6, 7, 8,
9,10,
11,12,13,14,15,16 } ;
ERROR
maksimu
m 15
elemen
Contoh - 3
Dev C++ 5.11
#include<stdio.h>
void main()
{char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
j=2;
{ printf( "%c ", A[0] [ j ] );
}
}
Apa yang tercetak : ?
Contoh – 3a
Borland Turbo-C++ A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
j=2;
{ printf( "%c ", A[0] [ j ] );
}
}
Apa yang tercetak : ?
Contoh – 3a
Borland Turbo-C++ A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
j=2;
{ printf( "%c ", A[0] [ j ] );
}
}
Contoh – 3a
C
Contoh - 4
Dev C++ 5.11
#include<stdio.h>
void main()
{char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
for( j=0; j<=4; j++ )
{ printf( "%c ", A[0] [ j ] );
}
}
Apa yang tercetak : ?
Contoh – 4
Dev C++ 5.11 A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
for( j=0; j<=4; j++ )
{ printf( "%c ", A[0] [ j ] );
}
}Apa yang tercetak : ?
Contoh – 4
j
elemen
yang isinya
dicetak
0
1
2
3
4
A[0][0]
A[0][1]
A[0][2]
A[0][3]
A[0][4]
Dev C++ 5.11 A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
for( j=0; j<=4; j++ )
{ printf( "%c ", A[0] [ j ] );
}
}
Contoh – 4
j
elemen
yang isinya
dicetak
0
1
2
3
4
A[0][0]
A[0][1]
A[0][2]
A[0][3]
A[0][4]
A B C D E
Dev C++ 5.11
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int j;
for( …………………… )
{ …………………………… );
}
}A B C D E
Contoh – 4
Tulis ulang !
supaya tercetak :
A B C D E
Pertemuan 1 - Algoritma dan Struktur Data 1
Contoh - 5
#include<stdio.h>
void main( )
{char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’
,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i;
for( i=0; i<=2; i++ )
{ printf( "%c ", A[i][0]);
}
}
Dev C++ 5.11
Contoh - 5
Apa yang tercetak : ?
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main( )
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i;
for( i=0; i<=2; i++ )
{ printf( "%c ", A[i][0]);
}
}
Dev C++ 5.11
Contoh - 5
Apa yang tercetak : ?
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main( )
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i;
for( i=0; i<=2; i++ )
{ printf( "%c ", A[i][0]);
}
}
Dev C++ 5.11
Contoh - 5
i
elemen
yang isinya
dicetak
0
1
2
A[0][0]
A[1][0]
A[2][0]
Apa yang tercetak : ?
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main( )
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i;
for( i=0; i<=2; i++ )
{ printf( "%c ", A[i][0]);
}
} A F K
Borland Turbo-C++
Contoh - 5
i
elemen
yang isinya
dicetak
0
1
2
A[0][0]
A[1][0]
A[2][0]
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
#include<stdio.h>
void main( )
char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i;
for( ……………………)
{ ……………………………..);
}
}
Borland Turbo-C++
Contoh - 5
i
elemen
yang isinya
dicetak
0
1
2
A[0][0]
A[1][0]
A[2][0]Tulis ulang !
supaya tercetak :
A F K
Pertemuan 1 - Algoritma dan Struktur Data 1
Contoh - 6
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Dev C++ 5.11Contoh - 6
Apa yang tercetak : ?
Tulis !
Apa yang
tercetak
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Dev C++ 5.11Contoh - 6
Apa yang tercetak : ?
i j
0 1
2
3
4
1 1
2
3
4
2 1
2
3
4
#include<stdio.h>
void main()
{char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Dev C++ 5.11Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
urutan
proses
#include<stdio.h>
void main()
{ char A[3][5]={ "ABCDE" ,
"FGHIJ" ,
"KLMNO" };
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
Tercetak :
A B C D E
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
Tercetak :
F G H I J
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
Tercetak :
K L M N O
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
Apa yang tercetak : ?
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
Tercetak :
A B C D E
F G H I J
K L M N O
#include<stdio.h>
void main()
char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for( i=0; i<=2; i++ )
{ for( j=0; j<=4; j++)
{ printf("%c ", A[i][j]);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
A B C D E
F G H I J
K L M N O
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(………………… )
{ for( …………………….)
{…………………………);
}
printf("n");
}
}
Borland Turbo-C++Contoh - 6
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
i j
0 0
1
2
3
4
1 0
1
2
3
4
2 0
1
2
3
4
Tulis ulang,
untuk mencetak :
ABC D E
FGH I J
KLMNO
Contoh - 7
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
Apa yang tercetak : ?
Tulis !
Apa yang
tercetak
#include<stdio.h>
void main()
{char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’
,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}Apa yang tercetak : ?
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
urutan
proses
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
Tercetak :
A F K
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
Tercetak :
B G L
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
Tercetak :
C H M
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
Tercetak :
D I N
#include<stdio.h>
void main()
{char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
Tercetak :
E J O
#include<stdio.h>
void main()
char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
AF K
BGL
CHM
D I N
EJ O
Tercetak :
A F K
B G L
C H M
D I N
E J O
#include<stdio.h>
void main()
char A[3][5] =
{ ‘A’,’B’,’C’,’D’,’E’ ,
‘F’,’G’,’H’,’I’,’J’,
‘K’,’L’,’M’,’N’,’O’ } ;
int i, j;
for(j=0; j<=4; j++ )
{ for( i=0; i<=2; i++)
{ printf("%c",A[ i][ j ]);
}
printf("n");
}
}
j i
0 0
1
2
1 0
1
2
2 0
1
2
3 0
1
2
4 0
1
2
A B C D E
0 1 2 3
4
F G H I J
K L M N 0
0
1
2
i
j
[ 0 ] [ 0 ]
[ 1 ] [ 0 ]
[ 2 ] [ 0 ]
[ 0 ] [ 1 ]
[ 1 ] [ 1 ]
[ 2 ] [ 1 ]
[ 0 ] [ 2 ]
[ 1 ] [ 2 ]
[ 2 ] [ 2 ]
[ 0 ] [ 3 ]
[ 1 ] [ 3 ]
[ 2 ] [ 3 ]
[ 0 ] [ 4 ]
[ 1 ] [ 4 ]
[ 2 ] [ 4 ]
[ 0 ] [ 0 ]
[ 1 ] [ 0 ]
[ 2 ] [ 0 ]
[ 0 ] [ 1 ]
[ 1 ] [ 1 ]
[ 2 ] [ 1 ]
----
----
[ 2 ] [ 4 ]
A F K
BG L
CHM
D I N
EJ O
Pertemuan 1 - Algoritma dan Struktur Data 1

More Related Content

PPTX
proposisi majemuk & Tautologi
DOCX
Statistika Deskriptif
PDF
Shortest Path Problem: Algoritma Dijkstra
DOCX
Contoh Analisis hasil ulangan harian
PDF
ALJABAR LINEAR ELEMENTER
PPTX
Analisis Time Series
PPTX
APG Pertemuan 4 : Multivariate Normal Distribution (2)
PPTX
Penerapan integral dalam bidang ilmu
proposisi majemuk & Tautologi
Statistika Deskriptif
Shortest Path Problem: Algoritma Dijkstra
Contoh Analisis hasil ulangan harian
ALJABAR LINEAR ELEMENTER
Analisis Time Series
APG Pertemuan 4 : Multivariate Normal Distribution (2)
Penerapan integral dalam bidang ilmu

What's hot (20)

PPTX
PPT Functional dan OOP Programming.pptx
DOCX
Rpp pertidaksamaan rasional dan irasional kurikulum 2013
PDF
1. Modul Ajar-Deret Aritmatika-Matematika Umum-Kelas 10.pdf
PPTX
Kelompok 1 matematika titik, garis, bidang dan kurva
PPT
Matematika Diskrit part 2
PDF
Buklet soal EGRA.pdf
DOCX
nilai eigen dan vektor eigen
DOCX
Lembar Kerja Peserta Didik Soal
PPTX
policy brief yang menarik.pptx
PDF
11 12 -pengurutan dan-pencarian
PDF
Sesi 1 PB&S
DOC
Rancangan Faktorial 2k
PPTX
Graf ( Matematika Diskrit)
PDF
1. RPP MEDIAN 1 aksi 1 oke 2.pdf
DOCX
Metode simpleks dua fase
DOCX
5. transformasi geometri
DOC
1 rpp pola bilangan
PPTX
Kombinasi, Permutasi dan Peluang ppt
PDF
Distribusi Sampling
DOCX
Modul sistem pertidaksamaan linear dan permasalahannya
PPT Functional dan OOP Programming.pptx
Rpp pertidaksamaan rasional dan irasional kurikulum 2013
1. Modul Ajar-Deret Aritmatika-Matematika Umum-Kelas 10.pdf
Kelompok 1 matematika titik, garis, bidang dan kurva
Matematika Diskrit part 2
Buklet soal EGRA.pdf
nilai eigen dan vektor eigen
Lembar Kerja Peserta Didik Soal
policy brief yang menarik.pptx
11 12 -pengurutan dan-pencarian
Sesi 1 PB&S
Rancangan Faktorial 2k
Graf ( Matematika Diskrit)
1. RPP MEDIAN 1 aksi 1 oke 2.pdf
Metode simpleks dua fase
5. transformasi geometri
1 rpp pola bilangan
Kombinasi, Permutasi dan Peluang ppt
Distribusi Sampling
Modul sistem pertidaksamaan linear dan permasalahannya
Ad

Viewers also liked (16)

PPTX
Seminar: PHP Developer for Dummies
PDF
Presentasi fordis kkp skripsi genap 1314 (pra sidang)
PPTX
5 Tahun Membuat Pesawat Kertas
PPTX
Pertemuan 4 - Struktur Kondisi IF
PDF
Seminar: Mau jadi Android User atau Developer?
PPTX
Pertemuan 5 - Struktur Kondisi IF (lanjutan)
PPTX
Quickstrat bootstrap
PDF
Modern PHP Developer
PPT
Chapter 01 - Introduction to Computers
PDF
Makalah seminar nasional matematika 2012 pgri
PDF
Fundamental CSS3
PDF
Digital marketing — an overview
PDF
What's it like being a Woman in Tech?
PDF
Working With Big Data
PDF
Privacy is an Illusion and you’re all losers! - Cryptocow - Infosecurity 2013
PDF
Visual Design with Data
Seminar: PHP Developer for Dummies
Presentasi fordis kkp skripsi genap 1314 (pra sidang)
5 Tahun Membuat Pesawat Kertas
Pertemuan 4 - Struktur Kondisi IF
Seminar: Mau jadi Android User atau Developer?
Pertemuan 5 - Struktur Kondisi IF (lanjutan)
Quickstrat bootstrap
Modern PHP Developer
Chapter 01 - Introduction to Computers
Makalah seminar nasional matematika 2012 pgri
Fundamental CSS3
Digital marketing — an overview
What's it like being a Woman in Tech?
Working With Big Data
Privacy is an Illusion and you’re all losers! - Cryptocow - Infosecurity 2013
Visual Design with Data
Ad

More from Achmad Solichin (20)

PDF
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
PDF
Materi Webinar Web 3.0 (16 Juli 2022)
PDF
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
PPTX
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
PDF
Webinar PHP-ID: Machine Learning dengan PHP
PPTX
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
PPTX
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
PPTX
Metodologi Riset: Literature Review
PPTX
Materi Seminar: Artificial Intelligence dengan PHP
PPTX
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
PDF
Metodologi Riset: Literature Review
PPTX
Depth First Search (DFS) pada Graph
PPTX
Breadth First Search (BFS) pada Graph
PPTX
Binary Search Tree (BST) - Algoritma dan Struktur Data
PPTX
Computer Vision di Era Industri 4.0
PDF
Seminar: Become a Reliable Web Programmer
PPTX
The Big 5: Future IT Trends
PPTX
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
PPTX
Workshop PHP: Laporan HTML, Excel, PDF
PPT
Pertemuan 07. File dan Direktori
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Materi Webinar Web 3.0 (16 Juli 2022)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Machine Learning dengan PHP
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
Metodologi Riset: Literature Review
Materi Seminar: Artificial Intelligence dengan PHP
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Metodologi Riset: Literature Review
Depth First Search (DFS) pada Graph
Breadth First Search (BFS) pada Graph
Binary Search Tree (BST) - Algoritma dan Struktur Data
Computer Vision di Era Industri 4.0
Seminar: Become a Reliable Web Programmer
The Big 5: Future IT Trends
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Workshop PHP: Laporan HTML, Excel, PDF
Pertemuan 07. File dan Direktori

Recently uploaded (6)

PDF
"ಶ್ರೀ ಕ್ಷೇತ್ರ ಚಂಪಕಧಾಮ ಸ್ವಾಮಿ ದೇವಾಲಯ""Sri Kshetra Champakadham Swamy Temple"
PPTX
PETA.pptx,a,amamamamamamamamamammamamamam
PDF
فێرکردن و فێربوونی مۆدێرن.pdf دەروازەیەک بۆ
PPTX
Coklat Beige Ilustrasi 3 Dimensi Tugas Kelompok Presentasi.pptx
PPTX
Slide Ibadah siang 29 mei 2025 jika .pptx
PDF
ಶ್ರೀ ಕ್ಷೇತ್ರ ಚಂಪಕಧಾಮ ಸ್ವಾಮಿ ದೇವಾಲಯSri Kshetra Champakadham Swamy Temple
"ಶ್ರೀ ಕ್ಷೇತ್ರ ಚಂಪಕಧಾಮ ಸ್ವಾಮಿ ದೇವಾಲಯ""Sri Kshetra Champakadham Swamy Temple"
PETA.pptx,a,amamamamamamamamamammamamamam
فێرکردن و فێربوونی مۆدێرن.pdf دەروازەیەک بۆ
Coklat Beige Ilustrasi 3 Dimensi Tugas Kelompok Presentasi.pptx
Slide Ibadah siang 29 mei 2025 jika .pptx
ಶ್ರೀ ಕ್ಷೇತ್ರ ಚಂಪಕಧಾಮ ಸ್ವಾಮಿ ದೇವಾಲಯSri Kshetra Champakadham Swamy Temple

Pertemuan 1 - Algoritma dan Struktur Data 1

  • 3. Pengertian array dua dimensi Array dua dimensi dapat dipandang sebagai gabungan array satu dimensi Pandanglah tiga buah array satu dimensi yang dibuat dengan int A1[5], int A2[5], int A3[5]. Ketiga buah array satu dimensi diatas, dapat digabung menjadi satu, sehingga terbentuk sebuah array yang disebut array dua dimensi yang biasanya diilustrasikan sebagai berikut :
  • 4. Array 1 Dimensi : char A[5] ; Array 2 Dimensi : char A[3][5] ; Isinya ada Tapi tidak diketahui Isinya ada Tapi tidak diketahui
  • 5. Array 1 Dimensi : char A[5] ; 0 1 2 3 4 Array 2 Dimensi : char A[3][5] ; 0 1 2 3 4 0 1 2 Jumlah kolom ( column ) Jumlah kolom Jumlah baris ( row ) Nomor Kolom ( index ) Nomor kolom Nomor baris
  • 6. Array 1 Dimensi : char A[5] ; 0 1 2 3 4 Array 2 Dimensi : char A[3][5] ; 0 1 2 3 4 0 1 2 Jumlah kolom Jumlah kolom Jumlah baris Nomor kolom Nomor kolom Nomor baris Isinya ada Tapi tidak diketahui Isinya ada Tapi tidak diketahui
  • 7. Array 2 Dimensi : char A[3][5] ; Sering disebut array 3 x 5
  • 8. Array 1 Dimensi : char A[5] = {‘A’,’B’,’C’,’D’,’E’} ; A B C D E 0 1 2 3 4 Array 2 Dimensi : char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’ , ‘K’,’L’,’M’,’N’,’O } ; A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2
  • 11. #include<stdio.h> void main() { char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 baris : 1 kolom : 2 Dev C++ 5.11 Contoh - 1
  • 12. #include<stdio.h> void main() { char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 H Dev C++ 5.11
  • 13. Array 2 Dimensi : 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 Dev C++ 5.11 H #include<stdio.h> void main() { char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); }
  • 14. #include<stdio.h> void main() { char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 DIULANG Apa yang tercetak ?
  • 15. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 H
  • 16. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[2][3] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 Apa yang tercetak ? Kalau ini : ?
  • 17. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[1][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 N
  • 18. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[3][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 Apa yang tercetak ? Kalau ini : ? 3 Apakah Error ?
  • 19. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; printf(" %c ", A[3][2] ); } 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 . Tercetak karakter sembarang sesuai dengan karakter apa yang ada pada lokasi tersebut saat itu TIDAK ERROR
  • 20. 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 char A[3][5]; A[0][0] A[0][2] A[1][3] ?
  • 21. 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 char A[3][5]; A[0][0] A[0][2] A[1][3] A[2][1]
  • 22. 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 char A[3][5]; A[0][0] A[0][2] A[1][3] A[2][1]
  • 24. 0 1 2 3 4 A B C D E F G H I J K L M N 0 0 1 2 char A[3][5]; i j 0 0 0 1 0 2 0 3 0 4 1 0 1 1 1 2 1 3 1 4 2 0 2 1 2 2 2 3 2 4 i j i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4
  • 25. Array 2 Dimensi : A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; Logical illustration 3 baris 5 kolom A B C D E 0,0 0,1 0,2 0,3 0,4 1,0 1,1 1,2 1,3 1,4 2,0 2,1 2,2 2,3 2,4 F G H I J K L M N 0 memory physical allocation secara fisik alamatnya contiguous 2,4 untuk menyatakan A[2][4]
  • 26. Array 2 Dimensi : A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 char A[3][5] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' } ; char A[3][5] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' } ; atau : atau :
  • 27. char A[3][5] = { ‘A’,’B’,’C’, ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’, } ; A B C 0 0 0 1 2 3 4 F G H I J K L 0 0 0 0 1 2 0 (NULL) 0 0 0 0 0 0 0 0 Karakter NULL semua bit-nya 0 (nol) Kalau dicetak dengan ; “ %c ” tercetak : spasi (blank “ %i “ tercetak : 0 (nol) “ %x “ tercetak : 00
  • 28. A 0 0 0 0 0 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 1 2 char A[3][5] = { ‘A’ } ; char A[3][5] = { 65 } ; atau : atau :
  • 29. char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’ , ‘K’,’L’,’0’,’N’,’O’ } ; 0 1 2 3 4 A B C D E F G H I J K L 0 N 0 0 1 2 NULL
  • 30. char A[3][5] = { "ABCDE" , "FGHIJ" , "KL NO" } ; 0 1 2 3 4 A B C D E F G H I J K L N 0 0 1 2 space space
  • 32. 0 0 0 0 0 0 0 0 Karakter NULL Kalau dicetak dengan : “ %c ” tercetak : spasi (blank) “ %i “ tercetak : 0 (nol) “ %x“ tercetak : 00 0 0 1 0 0 0 0 0 Karakter space Kalau dicetak dengan ; “ %c ” tercetak : spasi (blank) “ %i “ tercetak : 32 “ %x “ tercetak : 20
  • 34. Contoh - 2 #include<stdio.h> main() { int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9,20,22,11 }; printf(" %c ", A[1][2] ); return 0; } 0 1 2 3 4 5 12 17 10 7 15 6 25 2 19 4 9 20 22 11 0 1 2 Dev C++ 5.11 Apa yang tercetak : ?
  • 35. Contoh - 2 #include<stdio.h> void main() { int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9,20,22,11 }; printf(" %c ", A[1][2] ); } 0 1 2 3 4 5 12 17 10 7 15 6 25 2 19 4 9 20 22 11 0 1 2 Dev C++ 5.11 25
  • 36. int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9,20,22,11 }; int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9,20,22,11 }; int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9,20, 22,11 }; int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 0 1 2 3 4 5 12 17 10 7 15 6 25 2 19 4 9 20 22 11 0 1 2 atau : atau : atau : int A[3][5] = { 5,12,17,10,7, 15,6,25, 2,19,4,9, 20, 22,11 }; atau :
  • 37. int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9, } ; 0 1 2 3 4 5 12 17 10 7 15 6 25 2 19 4 9 0 0 0 0 1 2 Lokasi yang tidak diisi, otomatis diisi dengan 0 (nol) Hanya diisi 12 elemen 3 elemen terakhir tidak diisi
  • 38. int A[3][5] = { 5,12,17,10,7, 15,6,25,2,19, 4,9, } ; 0 1 2 3 4 5 12 17 10 7 15 6 25 2 19 4 9 0 0 0 0 1 2 int A[3][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,15,16 } ; ERROR maksimu m 15 elemen
  • 40. Dev C++ 5.11 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; j=2; { printf( "%c ", A[0] [ j ] ); } } Apa yang tercetak : ? Contoh – 3a
  • 41. Borland Turbo-C++ A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; j=2; { printf( "%c ", A[0] [ j ] ); } } Apa yang tercetak : ? Contoh – 3a
  • 42. Borland Turbo-C++ A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; j=2; { printf( "%c ", A[0] [ j ] ); } } Contoh – 3a C
  • 44. Dev C++ 5.11 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; for( j=0; j<=4; j++ ) { printf( "%c ", A[0] [ j ] ); } } Apa yang tercetak : ? Contoh – 4
  • 45. Dev C++ 5.11 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; for( j=0; j<=4; j++ ) { printf( "%c ", A[0] [ j ] ); } }Apa yang tercetak : ? Contoh – 4 j elemen yang isinya dicetak 0 1 2 3 4 A[0][0] A[0][1] A[0][2] A[0][3] A[0][4]
  • 46. Dev C++ 5.11 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; for( j=0; j<=4; j++ ) { printf( "%c ", A[0] [ j ] ); } } Contoh – 4 j elemen yang isinya dicetak 0 1 2 3 4 A[0][0] A[0][1] A[0][2] A[0][3] A[0][4] A B C D E
  • 47. Dev C++ 5.11 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int j; for( …………………… ) { …………………………… ); } }A B C D E Contoh – 4 Tulis ulang ! supaya tercetak : A B C D E
  • 50. #include<stdio.h> void main( ) {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i; for( i=0; i<=2; i++ ) { printf( "%c ", A[i][0]); } } Dev C++ 5.11 Contoh - 5 Apa yang tercetak : ?
  • 51. A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main( ) {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i; for( i=0; i<=2; i++ ) { printf( "%c ", A[i][0]); } } Dev C++ 5.11 Contoh - 5 Apa yang tercetak : ?
  • 52. A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main( ) {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i; for( i=0; i<=2; i++ ) { printf( "%c ", A[i][0]); } } Dev C++ 5.11 Contoh - 5 i elemen yang isinya dicetak 0 1 2 A[0][0] A[1][0] A[2][0] Apa yang tercetak : ?
  • 53. A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main( ) {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i; for( i=0; i<=2; i++ ) { printf( "%c ", A[i][0]); } } A F K Borland Turbo-C++ Contoh - 5 i elemen yang isinya dicetak 0 1 2 A[0][0] A[1][0] A[2][0]
  • 54. A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 #include<stdio.h> void main( ) char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i; for( ……………………) { ……………………………..); } } Borland Turbo-C++ Contoh - 5 i elemen yang isinya dicetak 0 1 2 A[0][0] A[1][0] A[2][0]Tulis ulang ! supaya tercetak : A F K
  • 57. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Dev C++ 5.11Contoh - 6 Apa yang tercetak : ? Tulis ! Apa yang tercetak
  • 58. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Dev C++ 5.11Contoh - 6 Apa yang tercetak : ? i j 0 1 2 3 4 1 1 2 3 4 2 1 2 3 4
  • 59. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Dev C++ 5.11Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 urutan proses
  • 60. #include<stdio.h> void main() { char A[3][5]={ "ABCDE" , "FGHIJ" , "KLMNO" }; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i
  • 61. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i Tercetak : A B C D E
  • 62. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i Tercetak : F G H I J
  • 63. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i Tercetak : K L M N O
  • 64. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 Apa yang tercetak : ? i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i Tercetak : A B C D E F G H I J K L M N O
  • 65. #include<stdio.h> void main() char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for( i=0; i<=2; i++ ) { for( j=0; j<=4; j++) { printf("%c ", A[i][j]); } printf("n"); } } Borland Turbo-C++Contoh - 6 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i A B C D E F G H I J K L M N O i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4
  • 66. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(………………… ) { for( …………………….) {…………………………); } printf("n"); } } Borland Turbo-C++Contoh - 6 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i i j 0 0 1 2 3 4 1 0 1 2 3 4 2 0 1 2 3 4 Tulis ulang, untuk mencetak : ABC D E FGH I J KLMNO
  • 68. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } Apa yang tercetak : ? Tulis ! Apa yang tercetak
  • 69. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } }Apa yang tercetak : ? A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j
  • 70. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2
  • 71. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 urutan proses
  • 72. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j Tercetak : A F K
  • 73. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j Tercetak : B G L
  • 74. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j Tercetak : C H M
  • 75. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j Tercetak : D I N
  • 76. #include<stdio.h> void main() {char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j Tercetak : E J O
  • 77. #include<stdio.h> void main() char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j AF K BGL CHM D I N EJ O Tercetak : A F K B G L C H M D I N E J O
  • 78. #include<stdio.h> void main() char A[3][5] = { ‘A’,’B’,’C’,’D’,’E’ , ‘F’,’G’,’H’,’I’,’J’, ‘K’,’L’,’M’,’N’,’O’ } ; int i, j; for(j=0; j<=4; j++ ) { for( i=0; i<=2; i++) { printf("%c",A[ i][ j ]); } printf("n"); } } j i 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 2 4 0 1 2 A B C D E 0 1 2 3 4 F G H I J K L M N 0 0 1 2 i j [ 0 ] [ 0 ] [ 1 ] [ 0 ] [ 2 ] [ 0 ] [ 0 ] [ 1 ] [ 1 ] [ 1 ] [ 2 ] [ 1 ] [ 0 ] [ 2 ] [ 1 ] [ 2 ] [ 2 ] [ 2 ] [ 0 ] [ 3 ] [ 1 ] [ 3 ] [ 2 ] [ 3 ] [ 0 ] [ 4 ] [ 1 ] [ 4 ] [ 2 ] [ 4 ] [ 0 ] [ 0 ] [ 1 ] [ 0 ] [ 2 ] [ 0 ] [ 0 ] [ 1 ] [ 1 ] [ 1 ] [ 2 ] [ 1 ] ---- ---- [ 2 ] [ 4 ] A F K BG L CHM D I N EJ O