33
Logika & Algoritma Pemrograman

Logika dan Algoritma pemrograman

Embed Size (px)

Citation preview

Page 1: Logika dan Algoritma pemrograman

Logika & AlgoritmaPemrograman

Page 2: Logika dan Algoritma pemrograman

● Android Developer di qiscus● Penulis buku “Livecoding! 9 Aplikasi Android

Buatan Sendiri”● [email protected] (email) | @omayib

(Twitter)

“jika pelukis memilki kanvas untuk mencurahkan imajinasinya,Maka programmer punya RAM yang bisa di manipulasi sesuai

imajinasi”

Arif Akbarul Huda

Page 3: Logika dan Algoritma pemrograman

Peanut Butter Robo Game

Singapore, March 2014

Page 4: Logika dan Algoritma pemrograman

They are learn about

● Instruction● logic

Page 5: Logika dan Algoritma pemrograman

What is programming?

● Series of instruction to a computer to accomplish a task

● Group of instruction will make a program to perform that particular task

Page 6: Logika dan Algoritma pemrograman

How to give instruction to Computer

Abcdefghaij blblblabla01100110001

Page 7: Logika dan Algoritma pemrograman

Programming languange

Page 8: Logika dan Algoritma pemrograman

What is Algorithms?

● List of step● Like the instruction for a recipe● Used for solving specific task or problem

Page 9: Logika dan Algoritma pemrograman

Sample taskTask : add two number

Algorithm :

Step 1: Start

Step 2: Declare variables num1, num2 and sum.

Step 3: Read values num1 and num2.

Step 4: Add num1 and num2 and assign the result to sum.

sum←num1+num2

Step 5: Display sum

Step 6: Stop

Page 10: Logika dan Algoritma pemrograman

What is flowchart looks like?

start

Get two number

Calculate both number

Show the result

finish

Page 11: Logika dan Algoritma pemrograman

What are symbols?

http://www.smartdraw.com/flowchart/flowchart-symbols.htm

Page 12: Logika dan Algoritma pemrograman

Wich is the oldest?

Nabila17 old

Vina12 old

Feyza15 old

Page 13: Logika dan Algoritma pemrograman

Wich is the oldest?

Step 1: StartStep 2: Declare variables a,b and c.Step 3: Read variables a,b and c.Step 4: If a>b If a>c Display a is the largest number. Else Display c is the largest number. Else If b>c Display b is the largest number. Else Display c is the greatest number. Step 5: Stop

Page 14: Logika dan Algoritma pemrograman

What is the flowchart look like?start

Get input as a, b, c

a>b

C as the oldestb>c

a>c A as the oldesty y

nn

B as the oldest

y

n

finish

Page 15: Logika dan Algoritma pemrograman

How does human perform simple task?

Add 345 and 155

500!

Page 16: Logika dan Algoritma pemrograman

1. She hear it trough input sense

2. Store the number 345 and 155 in his memory

3. Calculate those number in his brain and store the result in memory

4. She say the result trough output sense

Page 17: Logika dan Algoritma pemrograman

How does computer perform simple task?

1. Computer use keyboard to receive input

4. Computer user monitor to display output

3. Camputer calculate both number using CPU (with ALU inside) and

store back in RAM

2. Computer store the number 345 and 155 in RAM

Page 18: Logika dan Algoritma pemrograman

Element of Programming

Page 19: Logika dan Algoritma pemrograman

Write all number 1-100

start

i=1

i<=100? Print i

i++

stop

Page 20: Logika dan Algoritma pemrograman

● During programming, we my need to do following– Store data temporarily

– Control the normal flow of instruction

– Repeat one or more instruction several time

– Repeat group of instruction at several parts of program

http://www.slideshare.net/BaabtraMentoringPartner/algorithms-introduction-to-computer-programming on slide 48

Page 21: Logika dan Algoritma pemrograman

● During programming, we my need to do following– Store data temporarily (variable)

– Control the normal flow of instruction (Decission)

– Repeat one or more instruction several time (Loops)

– Repeat group of instruction at several parts of program (Function)

http://www.slideshare.net/BaabtraMentoringPartner/algorithms-introduction-to-computer-programming on slide 48

Page 22: Logika dan Algoritma pemrograman

variables

Page 23: Logika dan Algoritma pemrograman

Write all number 1-100

start

i=1

i<=100? Print i

i++

stop

Page 24: Logika dan Algoritma pemrograman

● Place to put data or value● Presented by letter or a word● Variable name can't contain space● Some of data types are String, Int, Boolean, Float● Example (java)

● int TOTAL_NUM = 10;● String city=””;

Page 25: Logika dan Algoritma pemrograman

DECISSION

Page 26: Logika dan Algoritma pemrograman

Write all number 1-100

start

i=1

i<=100? Print i

i++

stop

Page 27: Logika dan Algoritma pemrograman

● A program often needs to decide wheter something is true or

false in order to see which way to continue

● Also called conditional statement

● if...else

● Switch...case

Page 28: Logika dan Algoritma pemrograman

LOOP

Page 29: Logika dan Algoritma pemrograman

Write all number 1-100

start

i=1

i<=100? Print i

i++

stop

Page 30: Logika dan Algoritma pemrograman

● a loop is a sequence of instruction s that is continually repeated

until a certain condition is reached

● A loop often has a counter and continues to repeat a specified

number of times

● Some type of loop in programming

● For..

● While

● do...while

Page 31: Logika dan Algoritma pemrograman

FUNCTION

Page 32: Logika dan Algoritma pemrograman

start

finish start

i=1

i<=100? Print i

i++

stop

Page 33: Logika dan Algoritma pemrograman

● In most programming language, small sub-programs are

used to perform some of the task

● Functions usually "take in" data, process it, and "return" a result

● Once a function is written, it can be used over and over and

over again

● Functions can be "called" from the inside of other functions.