weeks – 01/ 1 introduction to computer programming and problem solving

32
Weeks – 01/1 Introduction to Introduction to Computer Programming Computer Programming and Problem Solving and Problem Solving

Upload: mary-grady

Post on 26-Mar-2015

225 views

Category:

Documents


2 download

TRANSCRIPT

Weeks – 01/1

Introduction to Computer Introduction to Computer Programming and Problem Programming and Problem

SolvingSolving

2

Lecturer Name : Rian F. Umbara, S.Si, M.Si Class Rules:

Attendance: min 80 %Late Tolerance: 15 minutesDo not cheatDo not open the internet without permission

2

Introduction

3

Referensi1. A Guide to Programming Logic & Design, Farrel,

Joyce, Course Technology2. Downey, Allen B. How to think like Computer

Scientist, Open Source Textbook, Waterville, 19993. Felleisen, Mathias, Findler, Robert B. Flatt Mathew,

Khrismurthi : How to Design Program : An Introduction to programming and computing, MIT Press, London

4. Handbook Poltek5. Other Books

4

DescriptionAn Introduction to algorithm and data structures,

program development life cycle, logic diagram, basic control structures (seq, if-else, repetitive) in the frame work of structural programming using Pascal as the programming language.

This course also introduce various levels in programming language for solving problems

5

Learning ObjectivesUpon to successful completion of the course

student have :1. Ability to solve problems by writing algorithms in a structured

way;2. Good understanding about data types such as numeric,

alphabetic, character and Boolean;3. Fundamental computer programming and the Pascal

language;4. Good concept of arrays and use of arrays;5. Ability in using Functions and their benefit in modular

decomposition;6. Good concept in String manipulation (parsing)7. Good understanding about User defined data type (record)8. Good concept in advanced data structures (linked table or

stack)

6

ScoringTest :

Mid : 25 %Final : 40 %

Pre test : 10 %Post test : 10 %Task : 15 %

Introduction

8

8

ObjectivesIn this lesson, you will learn about:

Defining how computer works electronically System Component : Input, Process, and

Output Defining levels of programming language Define wahat ‘program’ is Brief introduction in software engineering Using flowchart as a design tool Using Pseudocode as design tool

9

9

Overview of computers A computer is a collection of several electronic

components that work together to process instructions provided by a user.

You can use computers to: Solve complicated mathematical problems. Process large amounts of information without

errors. Automate day-to-day transactions. This reduces the

number of people required to perform a particular task.

Send e-mail messages to people across the world. Play games and indulge in recreational activities.

10

Computer Programming ?Computers do what we tell them to

do, NOT what we want them to do

Computer Programming involves writing instructions and giving them to the computer to complete a task.

10

11

11

• Hardware components are the physical components of a computer.

• Following are the hardware components of a computer:

• Input Devices

• Output Devices

• Processing Device

• Storage Devices

Hardware Components of a Computer

12

12

HARDWARE

13

13

SOFTWARE

14

Problem Solving

14

Problem

specification

Algorithm

Program

Executable (solution)

Design

Implementation

Compilation

Analysis

15

15

What is a (computer) program ?

A program is a sequence of instructions that specifies how to perform a computation.

The instructions (or commands, or statements) look different in different programming languages

Source ://OOPWeb.com : How To Think Like A Computer Scientist Learning with C++ by Allen B_ Downey

16

16

What Is Programming ? the act of creating software or some other set of instructions for a

computer.(cyber.law.harvard.edu/readinessguide/glossary.html)

The extrusion of a parison which differs in thickness in the length direction in order to equalize wall thickness of the blown container. ...(www.all-pak.com/plasticgloss.asp)

is the process of writing a sequence of instructions to be excuted by a computer to solve a problem. It is also considered as the act of writing computer programs. Computer programs are set of instructions that tell a computer to perform certain operations. ...(hubpages.com/hub/Concepts-and-Principles-of-Programming )

A system in which specific requirements of the client are determined in written form and, when approved by the client, become the basis for all future planning. The effects of successful programming will be felt by the client as long as he or she lives with the facility executed. ...(www.officespacefinder.co.uk/officespacegloss2.html )

17

17

Programming Language A programming language is an artificial language

that can be used to write programs which control the behavior of a machine, particularly a computer

Programming languages are defined by syntactic and semantic rules which describe their structure and meaning respectively

Thousands of different programming languages have been created so far, and new languages are created every year

18

Who Is a Programmer ?A programmer is a person who writes the

required computer programs.

Programmers translate the expected tasks given in human understandable form into machine understandable form by using compilers and interpreters.

18

19

Input and OutputNormally, a computer received two

kinds of input:the programthe data needed by the program.

The output is the result(s) produced by following the instructions in the program

19

2020

21

21

Programming LanguagesA language is a means of communication

between people.

A programmer writes a set of instructions in a programming language to instruct the computer to perform a task. This set of instructions is called a program.

22

22

Levels of Programming Languages

Programming languages can be classified into three broad categories :

• Machine Language • Assembly Language• High-level Language

23

Programming LanguagesMachine Language 0000100100010010

0010000100010100 0011100100010000 0001000100010110

Assembly Language LDA TIME ADA INC MUL VEL STA POS

High-level Language A = B * (C + D)

23

24

24

Basic Functions There are a few basic functions that appear in just about every

language: input

Get data from the keyboard, or a file, or some other device. output

Display data on the screen or send data to a file or other device. math

Perform basic mathematical operations like addition and multiplication.

testing Check for certain conditions and execute the appropriate sequence

of statements. repetition

Perform some action repeatedly, usually with some variation.

25

Compiler & InterpreterCompiler is a specific software that gets the

whole Source Code (Computer program written in human understandable form) and translates it into Object Code (Computer Program that is in machine understandable form) all at a time.

Interpreter is translating and executing one statement (command of Computer Program) of Source Code into Object Code at a time. (It means, interpreters translate and execute computer programs line by line).

25

26

26

• To execute a program written in a high-level language• A computer needs translation software called a compiler

• A compiler is language-specific, and each high-level language has its own compiler.

Compiler

27

27

• Some high-level languages use a different type of translator program called an interpreter.

• An interpreter takes a high-level language instruction, converts it to a machine language instruction, executes it and does not save the object code.

Interpreter

2828

Using Compiler:

Source Code Compiler Object Code

Execute ProgramExecute ProgramUsing Interpreter:

Execute a lineof Program

Execute a lineof ProgramSource Code Interpreter

29

Algorithms An algorithm is a sequence of steps required

to accomplish a task. The steps can be categorized into the

following three phases: Input phase Process phase Output phase

30

Program Design ToolFlowchart : the graphical representation of

algorithmsPseudocode : Pseudocode represents an

algorithm in English language.

31

31

• A flowchart consists of symbols, which represent the steps or stages in an algorithm.

• The different symbols used in a flowchart are

Representing Algorithm 1(Program Design Tool)

Input/Output

Process

Decision

Procedure/Subroutine

Start and Stop

Flow line

On Page Connector

Off Page Connector

preparation

32

32

• Pseudocode is used as an alternative to a flowchart. • The statements used in pseudocode are simple and written in a

sequential manner.• There are a number of keywords used in pseudocode:

• Dictionary• begin…end• Accept (Read/Input)• Display (write/Output)• if…then-else

Representing Algorithm 2 Pseudocode