15
chool of Computer Science & Information Technology G6DICP G6DICP Introduction to Computer Introduction to Computer Programming Programming Milena Radenkovic Milena Radenkovic

School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

Embed Size (px)

Citation preview

Page 1: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

School of Computer Science & Information Technology

School of Computer Science & Information Technology

G6DICPG6DICPIntroduction to Computer Introduction to Computer

ProgrammingProgramming

Milena RadenkovicMilena Radenkovic

Page 2: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

2

DefinitionsDefinitions ComputerComputer

Machine that processes data to produce a desired result Machine that processes data to produce a desired result (output).(output).

Very rapid execution of very simple instructions.Very rapid execution of very simple instructions.

Computer programComputer program The instructions required to achieve a desired end The instructions required to achieve a desired end

result.result.

Page 3: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

3

Computer HardwareComputer Hardware

The physical components of a computerThe physical components of a computer Electronic, Magnetic or MechanicalElectronic, Magnetic or Mechanical

System - a set of hardware devices connected to System - a set of hardware devices connected to make a functional computer.make a functional computer.

Computers are a set of switchesComputers are a set of switches MechanicalMechanical

Electro-mechanicalElectro-mechanical

Electronic (transistors)Electronic (transistors)

Integrated CircuitsIntegrated Circuits

Page 4: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

4

Binary EncodingBinary Encoding Binary is base 2Binary is base 2 Switches can easily encode binary data Switches can easily encode binary data

eg on=1, off=0eg on=1, off=0

Binary CountingBinary Counting

Decimal Binary 0 0 1 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000

Page 5: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

5

Bits & BytesBits & Bytes

1 binary digit is a bit1 binary digit is a bit Bits are physically arranged in groups of 8 called Bits are physically arranged in groups of 8 called

Bytes Bytes This is the basic unit of computer memory.This is the basic unit of computer memory.

0 0 0 10 0 0 0

1 0 0 00 0 0 0

0 0 0 01 0 0 0

1 1 1 11 1 1 1

1

8

128

255

Page 6: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

6

Bits & Bytes (cont.)Bits & Bytes (cont.)

One byte can encode an integer One byte can encode an integer from 0-255from 0-255

1024 Bytes = 1 Kilobyte1024 Bytes = 1 Kilobyte 1024 Kilobytes = 1 Megabyte1024 Kilobytes = 1 Megabyte

0 0 0 10 0 0 0

1 0 0 00 0 0 0

0 0 0 01 0 0 0

1 1 1 11 1 1 1

1

8

128

255

Page 7: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

7

Hardware ComponentsHardware Components

Central Processing Unit (CPU)Central Processing Unit (CPU) Memory (RAM)Memory (RAM)

Random AccessRandom Access

VolatileVolatile

Data stoarage devicesData stoarage devices Hard disk, floppy disk, tape, Hard disk, floppy disk, tape,

CD-ROM etc.CD-ROM etc.

Input devicesInput devices Keyboard, mouse, etc.Keyboard, mouse, etc.

Output devicesOutput devices Monitor, printer, speakers etc.Monitor, printer, speakers etc.

Page 8: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

8

Hardware SystemHardware System

RAM

CPU

Storage

Input Device Output Device

Page 9: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

9

Computer ProgramComputer Program

Set of instructions for CPUSet of instructions for CPU "Switch Settings""Switch Settings"

Machine languageMachine language

Assembly languageAssembly language Mmnemonics representing binary codeMmnemonics representing binary code

AssemblerAssembler

3rd Generation Languages3rd Generation Languages "High Level""High Level"

Compiled or InterpretedCompiled or Interpreted

Page 10: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

10

High Level Languages (3GL)High Level Languages (3GL)ExamplesExamples

FORTRANFORTRAN

COBOLCOBOL

PascalPascal

CC

C++C++

JavaJava

Page 11: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

11

Interpreted LanguageInterpreted Language

Source Code

Interpreter

Machine Code

Storage

CPU/memory

Program Execution

Page 12: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

12

Compiled LanguageCompiled Language

Source Code

Compiler

Storage

CPU/memory

Machine Code(executable binaries)

Program Execution

Page 13: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

13

Interpreted vs CompiledInterpreted vs Compiled

InterpretedInterpreted

Easy to develop Easy to develop (can be modified and executed in (can be modified and executed in one stage).one stage).

Distribution requirementsDistribution requirements(distribution of interpreter may be (distribution of interpreter may be cumbersome and/or expensive).cumbersome and/or expensive).

Machine code generated at Machine code generated at runtime - processing runtime - processing overhead.overhead.

CompiledCompiled

Development more cumbersomeDevelopment more cumbersome (compilation required when modified)(compilation required when modified)

Easy to distribute Easy to distribute (ie machine code is distributed)(ie machine code is distributed)

Machine code generated at Machine code generated at compile time - much more compile time - much more efficient.efficient.

Page 14: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

14

Layers of SoftwareLayers of Software

Hardware

Operating System

Application eg Word, Excel, Netscape etc.

eg Windows, Unix, MacOS etc.

eg PC, Macintosh etc.

Page 15: School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic

15

Operating SystemOperating System Provide basic services that access hardwareProvide basic services that access hardware

Input and DisplayInput and Display

i/o - eg disk filing system, communications etci/o - eg disk filing system, communications etc

User administration, security etcUser administration, security etc

Provide user interfaceProvide user interface Provide programmers with an API Provide programmers with an API

(Application Programming Interface)(Application Programming Interface)

Examples:Examples: MS Windows 95/98/MEMS Windows 95/98/ME MS Windows NT/2000/XPMS Windows NT/2000/XP Macintosh OS XMacintosh OS X Linux (Unix)Linux (Unix) Solaris (Unix)Solaris (Unix)