You are on page 1of 28

Algoritma dan Pemrograman (Praktikum Algoritma dan Pemrograman)

Kuliah #1 By Amil Ahmad Ilham http://www.unhas.ac.id/amil

Materi Kuliah
Bagian I: Amil Ahmad Ilham, ST., M.IT., Ph.D.
Slides dapat di download di: http://www.unhas.ac.id/amil/mk/2012_2/AP/

Bagian II: Adnan, ST., MT., Ph.D.

Penilai
Quiz Tugas Kelas Mid Test (Compulsory) Tugas Individu Tugas Kelompok Tutorial

TT Perkuliahan (NO rules)


No talking via mobile phone during class.
Silent mode is OK You can leave class if you have an urgent call.

No FB/Twitter/SMS during class. No kaos oblong and sandal. No smoking


You can eat snacks/candy during class.

No mark (zero) for late assignments without prior permission or urgent reasons. No mark (zero) for cheated assignments and exams.
4

What is a computer
Computer
is a device that receives input, stores and processes data, and provides output in a useful format.

Computers are NOT intelligent or telepathic


Computers do what we tell them to do they dont do anything by themselves.

Inside the personal computer

Close-up of PC motherboard

The Intel Pentium 4 processor


7

Computer Organization

Need for Programming


Computers are just electronic devices that have the power to perform difficult tasks but they do not KNOW what to do. Programmers tell the computers what to do by writing programs

Contoh Program Komputer


(Programmers tell the computers what to do by writing programs)

10

Contoh Program Komputer


(Programmers tell the computers what to do by writing programs)

11

What is a Computer Program?


A computer program is
a set of instructions written in a computer language executed to perform a specific task. Also called SOFTWARE

12

What is an Algorithm?
The plan for writing a program. The sequence of steps that describe solution of problem. Algorithms are written according to rules so that other programmers are also able to read and understand the solution easily.

13

Flowcharts
Flowcharts are graphical tools, containing a set of shapes, each expressing a different action in a sequence of program execution.

A Flowchart
shows logic of an algorithm emphasizes individual steps and their interconnections e.g. control flow from one action to the next

14

Pseudocode
Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is very similar to everyday English (Indonesian)
Biasanya dibuat sebelum menulis algoritma atau menggambar flowchart.

15

Start or stop Process

Input

Flowchart Symbols

Decision

Flow line Connector

Output

Off-page connector
16

Sequences
A sequence of instructions that are executed in the precise order they are written in:

statement block 1

statement block 1 statement block 2 statement block 3

statement block 2

statement block 3

17

Conditionals
Select between alternate courses of action depending upon the evaluation of a condition
If ( condition = true ) then statement block 1 else statement block 2 end if

True

False

condition statement block 1 statement block 2

18

Loops
Loop through a set of statements as long as a condition is true
Loop while ( condition = true ) statement block end Loop statement block
True

condition
False

19

Contoh#1
Tuliskan Pseudecode dan algoritma serta gambarkan flowchartnya untuk menghitung konversi derajat Fahrenheit ke Celcius. Pseudocode: Input derajat Fahrenheit Hitung derajat Celcius Print derajat Celcius

20

Contoh#1
Pseudocode:
Input derajat Fahrenheit Hitung derajat Celcius Print derajat Celcius

Algoritma
(Deskripsi/rincian langkah)
Input F C (F - 32.0) * 5.0 /9.0 Print C

21

Contoh#1
Flowchart

Algoritma (Deskripsi/rincian langkah)


Input F C (F - 32.0) * 5.0 /9.0 Print C

START

Input F

C (F - 32.0) * 5.0 /9.0

Print C

STOP

22

Contoh#1
Implementasi dengan bahasa pemrograman Java

23

Contoh#2
Tuliskan Pseudecode dan algoritma serta gambarkan flowchartnya untuk menentukan nilai tertinggi dari dua nilai yang diinput dan kemudian mencetak nilai tertinggi tersebut. Pseudocode: Input nilai A dan B Tentukan nilai tertinggi dengan membandingkan nilai A dan B Print nilai tertinggi

24

Contoh#2
Pseudocode: Input nilai A dan B Tentukan nilai tertinggi dengan membandingkan nilai A dan B Print nilai tertinggi Algoritma
(Deskripsi/rincian langkah)
Input A,B if (A > B then ) NT A else NT B endif Print NT

25

Contoh#2
Algoritma (Deskripsi/rincian langkah)
Input A,B if (A > B then ) NT A else NT B endif Print NT
Y START Input A,B

Flowchart

Apakah A>B ?

NT A

NT B

Print Nilai Tertinggi adalah, NT

STOP

26

Tutorial#1
1. Tuliskan pseudocode untuk mengganti ban kempes sebuah mobil dengan ban cadangan yang tersedia. 2. Tuliskan pseudocode untuk menyiapkan kopi manis di pagi hari (dimulai dari memasak air hingga menghidangkan kopi)

27

Tutorial
3. Tuliskan Pseudecode dan algoritma serta gambarkan flowchartnya:
a. Menghitung luas sebuah persegipanjang dengan menginput panjang dan lebar. b. Menghitung akar-akar persamaan kuadrat dengan menginput koefisien a, b dan c. c. Menentukan lulus atau tidak lulus mahasiswa berdasarkan rata-rata dari empat nilai yang diinput. Mahasiswa dinyatakan lulus jika nilai rata-ratanya lebih besar dari 50.
28

You might also like