0 évaluation0% ont trouvé ce document utile (0 vote)
19 vues7 pages
This document discusses arrays (larik) in Pascal/BASIC, including:
1) Arrays can have one or more dimensions and contain similar data types like integers or strings. They are identified by the array name.
2) Examples of one-dimensional arrays include arrays defined to hold a set number of elements or elements within a range.
3) A two-dimensional array example demonstrates inputting values and printing the 2D array.
This document discusses arrays (larik) in Pascal/BASIC, including:
1) Arrays can have one or more dimensions and contain similar data types like integers or strings. They are identified by the array name.
2) Examples of one-dimensional arrays include arrays defined to hold a set number of elements or elements within a range.
3) A two-dimensional array example demonstrates inputting values and printing the 2D array.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme PPTX, PDF, TXT ou lisez en ligne sur Scribd
This document discusses arrays (larik) in Pascal/BASIC, including:
1) Arrays can have one or more dimensions and contain similar data types like integers or strings. They are identified by the array name.
2) Examples of one-dimensional arrays include arrays defined to hold a set number of elements or elements within a range.
3) A two-dimensional array example demonstrates inputting values and printing the 2D array.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme PPTX, PDF, TXT ou lisez en ligne sur Scribd
mempunyai tipe data sejenis, misalnya numeris integer atau untai, dan diidentifikasikan dengan nama larik (perubah) Dimensi satu DIM barisTabel (10) DIM barisTabel (1 to 10) READ c DIM nilai(c) jumdat = 0 FOR i = 1 TO c READ nilai(i) NEXT i FOR i = 1 TO c jumdat = jumdat + nilai(i) NEXT i rerata = jumdat / c FOR i = 1 TO c PRINT USING "data nomor ## = ##.##"; i; nilai(i) NEXT i PRINT : PRINT "rata-rata= "; rerata: PRINT FOR i = 1 TO c PRINT USING "selisih data nomor ## dengan "; i; PRINT USING "ratarata = ##.###"; nilai(i) - rerata NEXT i DATA 10 DATA 85.6, 76.4, 87.6, 75.6, 86.5, 75.8 DATA 75.4, 95.2, 87.3, 95.4 Larik Dimensi Dua DIM matrixA (5, 8) DIM matrixA (1 to 5, 1 to 8) CLS DIM A(2, 2) FOR I = 1 TO 2 FOR J = 1 TO 2 INPUT A(I, J) NEXT J NEXT I FOR I = 1 TO 2 FOR J = 1 TO 2 PRINT A(I, J); NEXT J PRINT NEXT I END CLS DIM matrix(4, 4) FOR i = 1 TO 4 FOR j = 1 TO 4 READ matrix(i, j) PRINT matrix(i, j); NEXT j PRINT NEXT i
DATA 4,3,5,6 DATA 5,6,3,3 DATA 6,2,4,3 DATA 4,8,6,9