• Save
Pemrograman komputer 6 (repetisi)
Upcoming SlideShare
Loading in...5
×
 

Pemrograman komputer 6 (repetisi)

on

  • 815 views

unj fmipa-fisika

unj fmipa-fisika

Statistics

Views

Total Views
815
Views on SlideShare
813
Embed Views
2

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 2

http://widyalaya.info 2

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 6 (repetisi) Pemrograman komputer 6 (repetisi) Presentation Transcript

  • Pemrograman Komputer Pertemuan 06 Repetition 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 :
    • Mendemonstrasikan penggunaan perintah pengulangan
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • Outline Materi
    • The Do … Loop Structure
    • The For…Next Loop Structure
    • Nested Loops
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The Do … Loop Structure
    • Syntax and Action of the Do…Loop
      • Do
      • statementblock
      • Loop
    • Run Time: The Effect of the Do…Loop Structure
      • Statements in a loop’s interior are executed one at a time.
      • The Do marks the top of the loop.
      • The Loop sends the execution back to the top.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The Do … Loop Structure
    • Do While…Loop
      • Do While condition
      • statementblock
      • Loop
    • Run Time: The Effect of the Do While…Loop Structure
      • Loop continues to execute “while the condition is true.”
      • Loop is exited when the condition is false.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The Do … Loop Structure
    • Coding the Loop Body
      • One or more statements in the loop body must eventually cause the condition to become false.
      • Order of statements inside loop affects the result of the loop.
      • Loop may terminate immediately.
      • Loop can be viewed as a meta statement.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The Do … Loop Structure
    • Do Loop…While
      • Works like the Do While…Loop.
      • Termination at the bottom of the loop.
      • Syntax:
        • Do
          • statementblock
        • Loop While condition
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The Do … Loop Structure
    • Do Until…Loop and Do…Loop Until
      • Do Until…Loop
        • Termination condition at the top of the loop.
        • Same syntax and action as the Do While…Loop.
          • Except:
            • Difference in keywords.
            • Loop statements inside the Do Until…Loop are executed when the conditions are False.
      • Do…Loop Until
        • Termination condition at the bottom of the loop.
        • Exit when the condition is True.
    • Initialization and Termination
        • Loops may start or end at the wrong place.
          • The initialization statement may be off.
          • The condition operator may need to be changed.
          • The order of statements within the loop may need to be changed.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The For…Next Loop Structure
    • Syntax and Action of For…Next
      • For counter = start To end
        • statementblock
      • Next
      • Run Time: The Effect of the For…Next Structure
        • Counter variable and start and end expressions must be evaluated to control the number of times the loop will be processed.
    • For…Next versus Do…Loop Variations
      • Use a For…Next loop when the number of loop iterations can be determined.
      • Use a Do…Loop variety only when the number of iterations depends on the results of statements inside the loop.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • The For…Next Loop Structure
    • The Step Amount
      • Counter variable may be incremented by a step amount, such 3 instead of 1.
      • Syntax:
        • For counter = start To end Step increment
          • statementblock
        • Next
    • Avoiding For…Next Errors
      • Do not place statements inside the loop that change start , end , and increment expressions.
      • Do not change the counter variable inside the loop.
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • Nested Loops
    • Loops may be embedded inside of other loops.
    • Nested Do While…Loops
      • Do While condition1
        • statementblock1a
        • Do While condition2
        • statementblock2
        • Loop
          • statementblock1b
        • Loop
    • Nested For…Next Loops
      • For counter1 = start1 To end1
        • statementblock1a
        • For counter2 = start2 To end2
        • statementblock2
        • Next
          • statementblock1b
        • Next
    01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  • TERIMA KASIH 01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |