Вы находитесь на странице: 1из 27

Algorithm and Programming I

Week 1

Anggina Primanita, M.IT anggina.primanita@gmail.com


slide adapted from Algoritma Pemrograman-I: Drs. Megah Mulya, M.T & Samsuryadi, M.Kom

Subject at glance
Algorithm and Programming I 15 meetings Meetings will be carried out in both bahasa

Indonesia and English


subsequent slides can be accessed at :

http://is.gd/AlPro1_IF1A

Subject at glance
At the end of this subject, you will be able to:
distinguish various algorithm and programming

notations and programing languages choose correct usages of data types distinguish and using correct control structures distinguish correct usages between procedure and function in an algorithm. using pointers in algorithm and program development

Subject at glance
Textbooks:
Algoritma dan Pemrograman dalam Bahasa

Pascal dan C (Rinaldi Munir) Pemrograman C++: Membahas Pemrograman Berorientasi Objek Menggunakan Turbo C++ dan Borland C++ (Abdul Kadir Heriyanto)

Subject at glance
Markings system
No. 1. 2. 3. 4. 5. Markings Percentage Attendance and 5 punctuality Quizzes 15 Assignments 10 Mid-Sem Exam 30 Final Exam 40

No. 1. 2. 3. 4. 5.

Grades A B C D E

Range 85,55 100 70,55 85,54 55,55 70,54 40,55 55,54 < 40,54

Todays coverage
Definitions of Programming Definitions of Algorithm Terms in Algorithm and Programming

Introduction
Computers is used to help human solve their problem But to get computer to solve your problem can be

a problem :/
it cant be solve as it is computer is a machine, therefore it only knows machine language There should be a language that is known to both

human and computer


the problem is represented as a program

Programming: Introduction
Programming
has to based on a full comprehension over a

problem, analysis, and synthesis. Its not a trial and error process

Programming: Paradigm
Procedural/Structured/Imperative Functional Declarative/Predictive/Logical Object Oriented

Programming: Language
Procedural: Algol, Pascal, Fortran, Basic, Cobol, C Functional: LOGO, APL, LISP Declarative/Predictive/Logical: Prolog Object Oriented
pure OOP: Smalltalk, Eifel, Java hybrid: C++, Object Pascal

Programming: Language
From this point onwards, well be using C/C++ why?

Programming: on Learning
Learning programming language wont be the same

as learning how to program


learning programming language is related to

syntaxes, instructions, and how to use compiler on a computer learning how to program is related to problem solving strategies and how to express it into a structured notation

Programming: Logics
Is similar to computers
CPU
Processor Control Unit

Input device

Output Device

ALU

Input

Process

Output

Programming: How it works


Programming languages is translated into machine languages
Editor
#include <stdio.h> void main() { printf("Hello World"); }

compiled

.. mov ah,9 mov dx,offset hello_message int 21h .

hi lvl language

assembler language

data
1

11

12

13

14

15

16

17

18

19

MEMORY

21

22

23

24

25

26

27

28

29

PROCESSOR ALU

program
1

M O V M O V
22 23 12 13

A H , 9
16 17 27 26

11

14 24

15 25

18 28

19 29

21

MACHINE LANGUAGE

you need to find a way to clearly define a problem


Problem

Algorithms

High level language Assembly language

C C++ Java Basic

Execution

Compiler: - Turbo C++ - Borland C++ Builder - Turbo Pascal - Turbo Basic - Visual Basic Interpreter: - Basica - Dbase III++ - Java

Algorithm: Introduction
Definitions
logical steps to be taken to solve a problem domain According to Kamus Besar Bahasa Indonesia

Algoritma adalah urutan logis pengambilan putusan untuk pemecahan masalah

Algorithm: Origin
First implemented on Webster Dictionary in 1957,

the word Algorism is derived from Abu Jafar Muhammad ibnu Musa al-Khuwarizmi. The founder of this field of study

Algorithm: Usage
to command computers!

Algorithm: Example
switch!

Algorithm: Example
switch!

it takes 3 steps to switch places!

Algorithm: Important aspects


Finiteness

it has to stop at one point it has to be well defined it can have one ore more inputs before executed it can have one or more outputs it has to be effective

Definiteness

Input

Output

Effectiveness

Algorithm: in writing
Can be expressed in 3 ways:
natural language
daily conversational language can be ambiguous

flow chart
visually descriptive things can get complicated

pseudo-code
almost identical to programming language not everyone can understand..

Algorithm: Writing example


Case:

To distinguish between even and odd numbers.

Algorithm: Even vs Odd


in Natural language
Define a place in computer storage to keep the

number; namely x Read users input number If x divided by 2 and its remainder is 0, the word even will be displayed on the screen otherwise, the word odd will be displayed on the screen

Algorithm: Even vs Odd


as Flowchart

Start

int X

Read X

x%2 = 0 ? yes display even

no

display odd

End

Algorithm: Pseudo Code


Program Even_Odd {To distinguish whether a number is an even or odd based on data input using keyboard. Result will be displayed on screen as Even / Odd} Declaration x : integer

Algorithm read(x) if x mod 2 = 0 then write(Even) else write(Odd) endif

Вам также может понравиться