introduction to programming

24
HSIT 2130 Fundamentals of Programming By Budditha Hettige Department of Statistics and Computer Science 1

Upload: budditha-hettige

Post on 19-Jul-2016

33 views

Category:

Documents


0 download

DESCRIPTION

What is Computer Programing

TRANSCRIPT

Page 1: Introduction to Programming

HSIT 2130 Fundamentals of Programming

By Budditha Hettige

Department of Statistics and Computer Science

1

Page 2: Introduction to Programming

Overview

• Is Machine can solve problems?

• How Problem Solve by machine?

• What is Programming?

• What are Programming Languages

• Compilers

• Tools and Tips for Programming

• About Programming IDEs

2

Page 3: Introduction to Programming

Is machine can solve problems?

• Café Machine can be used to make a Tea

• ATM machine use to money transaction

• Calculator can be used to solve equation

• Each Machine has

– Input

– Output

– Do some process

3

Page 4: Introduction to Programming

Café Machine

• Input

– Sugar

– Water

– Tea

• Output

– Tea

• Process

– ????

Input

Output

Process

4

Page 5: Introduction to Programming

Calculator

• Input

– ???

• Output

– ???

• Process

– ???

5

Page 6: Introduction to Programming

ATM machine

• Input

– ???

• Output

– ???

• Process

– ???

6

Page 7: Introduction to Programming

Process of a Machine

• Work through the instructions given to it

– Read

– Write

– Do some Calculation

• Goto other instraction

• The sequence of instructions is call

Program

7

Page 8: Introduction to Programming

What is a Programming?

• Programming is the way to give

instructions

• Each Program has

– Start

– Do some work

– End

• Program is given through the machine

understood language

8

Page 9: Introduction to Programming

What is Computer?

• Is a machine that can solve problems

for people by carrying out instructions

given to it

• The sequence of instructions is call

Program

• The language machine can understand

is call machine language

9

Page 10: Introduction to Programming

What is Machine Language?

• Machine language(ML) is a system of

instructions and data executed directly by a

computer's Central Processing Unit

• The codes are strings of 0s and 1s, or binary digits

(“bits”)

• Instructions typically use some bits to represent

– Operations (addition )

– Operands or

– Location of the next instruction.

10

Page 11: Introduction to Programming

Machine Language contd..

• Advantages

– Machine can directly access (Electronic

circuit)

– High Speed

• Disadvantages

– Human cannot identify

– Machine depended

(Hardware depended)

11

Page 12: Introduction to Programming

About Machines & Languages

• Machine defines a language

– Set of instructions carried out by the

machine

• Language defines by the machine

– Machine executing all the program, writing

in the language

Machine Language Language

12

Page 13: Introduction to Programming

Computer Language(s)

• Machine contains

New Languages

(Ln) and the

Machine language

(LO)

Programming Language(Ln)

Machine Language (L0)

Translate/ Interpreter

Machine Program

ming Language

(Ln)

Machine Language

(L0)

13

Page 14: Introduction to Programming

Translation (L1 L0)

1. Replace each instruction written in L1 in to

LO

2. Program now execute new Program

3. Program is called compiler/ translator

14

Page 15: Introduction to Programming

Interpretation

• Each instruction in L1 can execute

through the relevant L0 instructions

directly

• Program is call interpreter

15

Page 16: Introduction to Programming

Language Level Machine

16

High-level Language Program (C, C++)

Assembly Language Program

Machine Language

Page 17: Introduction to Programming

Programming Language

• is an artificial language designed to

communicate instructions to a machine

• Programming Language has

– Keywords

– Syntax

– Semantics

17

Page 18: Introduction to Programming

Low-level Languages

• An assembly language command such as ADD X Y Z might mean add the values found at x and y in memory, and store the result in location z.

• Assembly language must be translated to machine language (zeros and ones) 0110 1001 1010 1011

• The CPU can follow machine language

18

Page 19: Introduction to Programming

High-level Languages

• Common programming languages include … C, C++, Java, Pascal, Visual Basic FORTRAN COBOL, Lisp

• These high – level languages – Resemble human languages

– Are designed to be easy to read and write

– Use more complicated instructions than the CPU can follow

– Must be translated to zeros and ones for the CPU to execute a program

19

Page 20: Introduction to Programming

Compilers

• Translate high-level language to

machine language

• Input (Source code)

– The original program in a high level language

• Output (Object code)

– The translated version in machine language

• Example

– C++ compiler, JAVA Compiler etc.

20

Page 21: Introduction to Programming

Tools & Tips for programming

• Source code Editor

– TextPad, Notepad

• Compiler

– JAVA Compiler, C++ compiler

• Language Knowledge

• Logical thinking ability

21

Page 22: Introduction to Programming

Programming with IDE

• IDE : integrated design environment

• consists of

– source code editor

– compiler and/or an interpreter

– build automation tools

– Debugger

– Construction of a GUI

– Class browser

– Object inspector

– Etc.

22

Page 23: Introduction to Programming

Programming IDEs

• Eclipse

Eclipse is a multi-language software development environment

http://www.eclipse.org/

• Netbeans

http://netbeans.org/

• Microsoft Visual Studio

http://www.microsoft.com/visualstudio/en-us

23

Page 24: Introduction to Programming

Exercise 1. To solve the following problems, identify the input,

output and the process a. Find the area of a room

b. Search a place of a city

c. Calculate grade for the given mark

2. What are the differences between compiler and

interpreter?

3. Why High-level language are useful than the Low-

level languages

4. Why Low-level is useful?

5. Search what are the compilers and IDE/Editors

available for the JAVA programming?

6. Search what are the existing Java based

applications?

24