algorithm and programming introduction dr. ir. riri fitri sari mm msc international class electrical...

22
Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February 2009

Upload: josephine-hamilton

Post on 14-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm and Programming Introduction

Dr. Ir. Riri Fitri Sari MM MScInternational Class

Electrical Engineering DeptUniversity of Indonesia

8 February 2009

Page 2: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Text Book• C++ How to Program, Fifth Edition• By H. M. Deitel -  Deitel & Associates, Inc., P. J. Deitel -

 Deitel & Associates, Inc.• Publisher: Prentice Hall• Pub Date: January 05, 2005• Print ISBN-10: 0-13-185757-6e• Text ISBN-10: 0-13-186103-4• Print ISBN-13: 978-0-13-185757-5e• Text ISBN-13: 978-0-13-186103-9• Pages: 1536

Page 3: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Chapter 1 Introduction

Page 4: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Programming

• Programming: The process of making a program

Page 5: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Programming Stages

• Definition

• Problem description

• Design of steps to solve the problem algorithm– Using flow chart– Using Pseudocode

• Coding

Page 6: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Problem

Problem definition

Problem Description

Design and Coding

Program

Testing with computer

Ready to use

ProgramA

A

Page 7: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Problem

Problem definition

Problem Description

Algorithm Design

Program

Testing with Computer

Ready to use program

A

Algorithm

Coding

A

Page 8: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Programming

• Algorithm written in programming language: Program

• The process to change an algorithm to be a program: Coding

• Every steps is prone to error:– Syntax Error compiler/interpreter– Logical Error

Page 9: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Programming

• There is a program which can be executed without the need to be interpreter beforehand (with interpreter):– BASIC– dBASE

Page 10: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why Algorithm?

• Obeying Rules syntax– Logical thinking

• Limitation on capability; –COBOL Large Data processing

–FORTRAN Calculation

Page 11: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why algorithm?

• Program Self Characteristics:– Ways of thinking– Logical approach– Detailed problem description– Perseverance– Enthusiasm

Page 12: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why Algorithm?

• Overcome the problem with other general and free language:– natural langunge– pseudo-code– flow chart

• Separate the activity of algorithm design and coding.

Page 13: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why Algorithm?

• Natural Language

unable to describe the problem solving stages with the following character:– structured– detailed– unambiguious

Very different from programming language.

Page 14: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why Algorithm?

• pseudo-code

Good to describe algorithm, for the following character:– structured– detailed– clear

Page 15: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Why Algorithm??

• Efficient program: Program which required minimum memory and fastest execution time.

Page 16: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm Definition

Steps to solve a problem or work which is defined as a systematic, detaild and clears, so that it can be conducted based on a particular condition, and can be completed in a limited time and produce results as required.

Page 17: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm Characteristic

• Structured

• Efficient

• Detailed

• Unambiguous

• Independent

Page 18: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm Characteristics

• Structured: – Consist of some steps, block, procedure and

function.– One entry point and one exit point.– The control flow follows a particular pattern.– Easy to manage and develop.

Page 19: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm Characteristics

• Eficient:

– Optimized the use of memory and processor. • Time :

–Processor to run command– Avoid long execution

Page 20: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm Characteristics

• Detail : – Easy to be describe as one or more

programming languange command. – Unambiguious

• Independent– independent from any programming

language.

Page 21: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Algorithm

• Problem-> sub problem -> easy to conduct.

• Smaller sub problem to be completed.

• Programming.

• Top Down Design

Page 22: Algorithm and Programming Introduction Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 8 February

Task:Install Devcpp4.9.9.2Run the hello worldRun the program 2.17 and modify for odd and even number