1 / 15

Latihan

Latihan. Buat algoritma untuk menampilkan output berikut : * * * * *. Buat algoritma untuk menampilkan tulisan berikut : iteration number 1 iteration number 2 iteration number 3 iteration number 4 iteration number 5 after loop ends.

shauna
Download Presentation

Latihan

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Latihan

  2. Buatalgoritmauntukmenampilkan output berikut: * * * * *

  3. Buatalgoritmauntukmenampilkantulisanberikut: iteration number 1 iteration number 2 iteration number 3 iteration number 4 iteration number 5 after loop ends

  4. Buatalgoritmauntukmenampilkan output berikut student no-1 is : student no-2 is : student no-3 is :

  5. Buatalgoritmauntukmenerimainputantigabuahbilangan real, lalumenghitung rata-ratanya, danmenampilkanhasilnyakelayar

  6. Write the algorithm to calculate cost of electricity with following constraints : (KWHs) Rate 0 - 500 2000 501 - 1000 2000 + 0.03 * per KWH over 1001 3500 + 0.02 * per KWH Enter the values of previous month meters, current month meter, and then displays the total cost which would exist.

  7. The structure of the FOR-TO-DO statement FOR counter variableinitial_valueTO final_value program statement ENDFOR

  8. START {initialize} Counter >= initial_value AND counter <= final_value ? action END Flowchart FOR-TO-DO No yes

  9. Example 1 Flowchart START Pseudocode FOR x1 TO 5 DO output (x) ENDFOR x >=1 AND x <= 5 ? No yes output (x) END

  10. Example 2 Pseudocode OUTPUT('before loop starts') FOR i = 1 TO 5 DO OUTPUT('iteration number ',i) ENDFOR OUTPUT('after loop ends')

  11. Execution • generates the output

  12. Example 3 FOR i  1 TO 5 DO Output (‘*’) {action statement} ENDFOR {end loop} The result of program : * * * * *

  13. Example 4 • Program with enter the value of 3 student’s scores : Pseudocode FOR i  1 TO 3 DO Output (‘Score student no-‘,i,’ is:’) Input (score) ENDFOR • Execution : • Score student no-1 is : __ • Score student no-2 is : __ • Score student no-3 is : __

  14. Example 5 • Average of 3 numbers number  0 {initialize} FOR i  1 TO 3 DO Input (x) {input value of x} number  number + x {sum of x variables} ENDFOR average  number/ 3 {calculate the average} Output (average)

More Related