• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Pemrograman komputer  11 (array)
 

Pemrograman komputer 11 (array)

on

  • 642 views

unj fmipa-fisika

unj fmipa-fisika

Statistics

Views

Total Views
642
Views on SlideShare
641
Embed Views
1

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 1

http://widyalaya.info 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Pemrograman komputer  11 (array) Pemrograman komputer 11 (array) Presentation Transcript

    • Pemrograman Komputer Pertemuan 11 Array Bambang Heru Iswanto, Dr.rer.nat M.Si
      • Jurusan Fisika
      • Fakultas Matematika dan Ilmu Pengetahuan Alam
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Learning Outcomes
      • Pada akhir pertemuan ini, diharapkan mahasiswa
      • akan mampu :
      • Menerapkan penggunaan array dalam aplikasi
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Outline Materi
      • Introduction to Array
      • Declaring an Array
      • Using Arrays
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Introduction to Array
      • Up to now, we have dealt with single value data only: e.g. -47.29, True, “Smith”
      • For each data item we have used a single variable name: e.g. sum, endOfInput, aName
      • Suppose we need to store the names of everyone in this group.
      • We could use a unique name for each variable, e.g. name1, name2, name3 …
      • This would be time-consuming, tedious and unworkable with even larger sets of numbers
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • List Structures
      • We can treat this kind of data as a group of related items, rather than separate ones
      • We can reserve a storage area large enough for all the values then assign a name to the area
      • This data structure may be called a single-level table, a list, a vector or a one-dimensional array
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Array Subscripts
      • The group (array or list) is given a name, but the individual items in the group are referred to by their position in the array – using a subscript in brackets
      • So with a group called students, students(3) is the 4 th value (as the numbering starts at 0).
      • It is similar to a street where all the houses have the same street name, but are distinguished by their house number.
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Why Use Arrays
      • Being able to group data into lists or arrays is an advantage
        • mirrors the real world way of working
          • much data in business and science is already grouped
        • allows computer memory to be used most effectively
          • efficient allocation of storage to variables
          • faster data access to array elements
        • allows the writing of efficient program code
          • write the code to process one value in the array
          • then make it repeat for all the other values
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Common Array Processing Task
      • Array initialisation
      • Input of data to an array (from keyboard or external data file)
      • Output of the contents of an array (to screen or external data file)
      • Searching an array for a specific value
      • Counting or summing values in the array
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Array
      • Imagine we need to store the marks of a group of 10 students studying VB. We decide to store the marks in an array called VBmarks.
      • If we could visualise the array, it might look like this.
      VBmarks(0) VBmarks(9) 01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Declaring an Array
      • To declare an array, we need to:
        • give the array an identifier
        • state how many data elements the array should hold
        • specify the type of data to be held in that array
      • E.g.
        • Dim vbMarks (0 To 9) as Integer
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
    • Initialize the Array
      • It is good practice to initialise (set to a known value) variables before use.
      • So we will initialise all the array elements to zero:
      • FOR posisi = 0 TO 9
      • VBmarks( posisi ) = 0
      • NEXT posisi
      • You might now visualise the array as this:
      01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id | 0 0 0 0 0 0 0 0 0 0
    • TERIMA KASIH 01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |