Top Banner
1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING
73

1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

Jan 12, 2016

Download

Documents

Richard Doyle
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

1

INTRODUCTION TO COMPUTER SCIENCE

CONCEPTS AND

PROGRAMMING

Page 2: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

2

Outline

• Part I: An overview of Computer Science.

• Part II: Computer hardware and software.

• Part III: Computer languages.

Page 3: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

3

Part I: An Overview of Computer Science

Page 4: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

4

What is Computer Science?

The study of how to solve problems with computers:

1) Design and build a computer

Cpsc-321 Computer Architecture Cpsc-462 Microcomputer Systems Cpsc-469 Advanced Computer Architecture Cpsc-483 Computer Systems Design and others.

Page 5: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

5

2) Use and share the computer efficiently:

Cpsc-311 Analysis of AlgorithmsCpsc-410 Operating SystemsCpsc-431 Software EngineeringCpsc-436 Computer-Human InteractionCpsc-437 Software Engineering Products and others.

Page 6: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

6

3) Communicate a solution to a Computer:

Cpsc 121- Intro to CS Concepts & Pgming.Cpsc 221- Data Structures and Their Implications.Cpsc 310- Database Systems.Cpsc 332- Programming Language Design.Cpsc 334- Compiler Design.Cpsc 438- Distributed Objects ProgrammingCpsc 442- Scientific Programming.Cpsc 452- Robotics & Spatial Intelligence. and others. 3

Page 7: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

7

Semantics Vs. Syntax

Syntax: The grammar rules for writing code in a program.

Semantics: The meaning of the code. The action that will be executed.

How you write the code vs. why you write the code.

Page 8: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

8

4) Find a solution automatically:

-Artificial Intelligence (CPSC 320).

5) Make your solution easier for people to use:- Human-Computer Interaction (CPSC 436).

6) Solve BIG problems:- Software Engineering (CPSC 431) .

7) Exploit multiple computers:-Parallel and Distributed systems, Networking.

Page 9: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

9

Real-life programs are usually:

• large (thousands of lines of code).• created by teams of people.• modified over the course of years.

Rules and methods are needed to cope with this complexity.

Computer Science is more than Programming!

Page 10: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

10

Part II: Computer Hardware and Software

Page 11: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

11

Outline• The development of modern computer

systems.

• Computer organization.

• Solving problems on computers.

• Programming and software engineering.

Page 12: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

12

The Development of Modern Computer Systems

•Early electronic computers.

•Computer Architecture.

•Time sharing.

•Microcomputers.

•Networked computing.

Page 13: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

13

Early Electronic Computers

• ENIAC (1946) - Electronic Numerical Integrator and Calculator.– First general purpose purely electronic digital

computer.– Built for US Army to make calculations for

weather predictions & ballistics tables.

– 18,000 vacuum tubes, space 50 X 30 ft, weighed 30 tons.

– Numbers are entered by manually setting its 6000 switches.

Page 14: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

14

• EDVAC - Electronic Discrete Variable

Calculator.– Executed a general instruction set and a stored

program.

– Both numbers and program instructions were stored electronically in the computer’s memory.

• UNIVAC - Universal Automatic Computer.

– First commercially built computer.

– Delivered to the U.S. Census Bureau in 1951 to tabulate the results of the previous year’s census.

Page 15: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

15

Computer Architecture

• Generations:– The development of modern computers is

often described in terms of the “generation”, in which a particular technology was used.

• Design:– The overall design of a computer’s electronic

circuitry and its logical functionality is called its architecture.

Page 16: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

16

Mainframes

• First generation – 1940s/1950s

Architecture:

Electronic Circuitry: Vacuum Tubes

Stored program:• Program: machine language.

• Processing: a single program at a time.

Peripheral devices:– Input and output: punched cards.– Data storage: magnetic tapes.

Page 17: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

17

Second and Third Generations

1960’s

• Electronic circuitry: transistors to integrated circuits (ICs).

– Symbolic Languages:• Assembly languages.• High-Level languages:

FORTRAN - FORmula TRANslation, first high- level language. COBOL - COmmon Business-Oriented Language. LISP - LISt Processing.

Page 18: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

18

– Translators: translating high-level language to machine-understandable form.

• Assemblers: converting program instructions from assembly languages into the machine language.

• Compilers: translating program statements from FORTRAN and COBOL to machine language.

• Interpreter: translating and executing each program statement dynamically.

Page 19: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

19

– Operating Systems (OS): a program to control the overall processing of the machine.

• Batch processing: jobs that were similar in their requirements were grouped together into batches and run sequentially.

• JCL (Job Control Language): to minimize operator intervention, JCL cards were inserted between the card decks of each job to direct how each job was to be processed.

• Mass storage: disk drives provide permanent storage and fast access to large quantities of data.

Page 20: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

20

Microcomputers

• Fourth generation – 1970s.– Chip circuitry: VLSI - Very Large Scale

Integration, which could contain all logic circuits on a single chip. These chips were known as microprocessors.

• Minicomputers – 1970s.– Lower cost and more accessible computing

power.– Architecture is based on the 16-bit (vs. the 32-

bit in use for larger computers) representation of data in computer memory.

Page 21: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

21

• PC - Personal Computer – 1970s-1980s.– Low cost computers intended for personal use.

• Input: keyboard.• Output: screen.• Data storage: removable floppy disks.• Examples: Apple, IBM PC.

– DOS - Disk Operation System.

• DOS was developed by Microsoft for the IBM PC.• DOS provides the basic functions for a single user

to handle data storage and to control input and output devices and program execution.

Page 22: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

22

GUI – Graphical User Interface.

• With the introduction of the Mac (Macintosh) computer by Apple in 1984.

• Information was presented to the user via pictures, known as icons.

• A new hand-held input device, called a mouse, was available for selecting choices from the screen.

• Each graphical image is composed of small dots called pixels which must be manipulated individually by the computer ‘s programs.

Page 23: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

23

• PC software.

– Software are programs directing a computer’s operations and solving problems.

– Hardware are the physical devices that form the computer itself.

– The popularity of PCs grew rapidly in the 1980s as innovative application programs were developed to enable non-technical users to do useful tasks on the computer.

Page 24: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

24

• Word processors allow a user to write and edit text.

• Spreadsheet programs provider convenient computational power for data stored in tables.

• Business graphics programs are able to display data in the form of graphs and charts.

Page 25: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

25

• Workstations – 1980s.

– For complex number crunching scientific and engineering programs.

– For a single user.

– Using multiprocessing systems.

– Well suited for networking use.

Page 26: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

26

Networked Computing

• Computer networks – 1980s-present.– Users access computers which are at a

distance.– Users share data.– Users transmit messages between computers.

• Telephone lines.– An electronic device called a modem allows

computers to transmit data over telephone lines,

Page 27: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

27

• LAN – Local Area Network.– A LAN allows computers in reasonable proximity of

each other to be connected by cabling over which data can be transmitted from one machine to another without the use of telephone lines.

• Distributed Computing.– Techniques of shared processing over networks are

generally called distributed computing.

– A computer that provides the core of the services is called a server.

– Any computer requesting a service is known as a client.

Page 28: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

28

Computer Organization

•Data representation

•Main Memory

•Central Processing Unit

•Secondary Storage

•Input / Output

Page 29: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

29

• The information which a computer processes is generally known as data.

• Individual data values may represent numbers, alphabetic characters, or other coded information.

• The computer programs which direct the computer’s operations are also data, because the instructions which they contain must be stored in the computer’s memory before they are able to be processed.

Page 30: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

30

• All data is stored and processed in binary form, that is, as a series of 0s and 1s.

• Each binary digit, called a bit, represents the smallest unit of information which can be stored in the computer.

• Bits are grouped into longer units known as bytes to hold more meaningful data.

– 1 byte = 8 bits

Page 31: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

31

• Two standard coding systems.

– ASCII – American Standard Code for Information Interchange.

• “Help” 01001000 01000101 01001100 01010000

128 64 32 16 8 4 2 1H -> 72 27 26 25 24 23 22 21 20

0 1 0 0 1 0 0 0

– EBCDIC – Extended Binary Coded Decimal Interchange Code

• Hello 11001000 11000101 11010011 11010011 11010110

Page 32: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

32

Main Memory

• Main memory is that part of a computer’s electronic circuitry which holds in binary form the program to be executed and any data that the program requires.

• Memory is divided into cells.

• Each cell is assigned a specific address, from 0 to the maximum size of the computer’s memory capacity.

Page 33: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

33

• The size of a computer’s memory is the number of the addressable cells it contains.

Bit 1Byte 8 bitsKilobyte210 bytes 1,000Megabyte 210 kilobyte 1,000,000Gigabyte 210 megabyte 1,000,000,000Terrabyte 210 Gigabytes one trillion

e.g. 256K bytes of memory have, 256 * 1024 = 262,144 bytes.

Page 34: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

34

• ROM – Read-Only Memory, is a specialized part of main memory which is designed to prevent data loss when the power to the computer is turned off.

– Read-Only.– Permanent.– Typical use: ROM is reserved for critical

program instructions which must be immediately available when a computer is first turned on( bootstrap pgm ).

Page 35: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

35

BootStrap Program

• Program that is automatically executed when the machine is turned on.

• It directs the CPU to transfer programs (in most cases it is the Operating System) and data from a predetermined location into the volatile area of main memory.

• The Op Sys takes over and begins controlling the machine’s activities.

Page 36: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

36

Central Processing Unit

• CPU is the heart of a computer.

– Control unit contains the circuitry for coordinating the machine’s activities.

– Arithmetic/Logic Unit (ALU) contains the circuitry that performs all arithmetic computations and logic operations.

Page 37: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

37

• BUS- For the purpose of transferring bits, a machine’s CPU and Main Memory are connected by a bus.

• The CPU extracts(reads) data from main memory by supplying the address of the pertinent memory cell along with a read signal.

• The CPU places(writes) data to memory by provided the address of the destination cell and the data to be stored, along with a write signal.

Page 38: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

38

CPU Main Mem

ALU Control ROM

unit Bus

Register Mem Volatile Mem

Page 39: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

39

Register Usage

• Program Counter (PC) is a special-purpose memory location which always contains the memory address of the instruction that is currently being executed.

• Instruction Register (IR) is another special-purpose memory cell which contains the instruction currently being processed.

Page 40: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

40

Hardware Characteristics:

• CPU synchronizes its operations by the regular pulses emitted by an electronic device called a clock.

• The speed of a computer can be quoted as:– Clock speed, e.g. 100MHz means 100

million cycles per second(megahertz).

– MIPS, a million instructions per second

Page 41: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

41

Arithmetic/Logical Unit (ALU) performs all arithmetic computations and logical operations.

Arithmetic - Add, subtract, multiply, divide, exponentiation etc.

Logical - Testing for relationships.

A<B; Name = ‘mary’;C >=10; possible Answers? True or False

The ALU contains special memory cells, known as registers, in which the arithmetic is carried out.

Page 42: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

42

reads the individual program

instructions from main memory. Executes the instructions 1 at a time until completion.

Fetch - Decode - Execute

The machine cycle algorithm is continuously repeated until program termination.

CPU

Machine Cycle

Page 43: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

43

Fetch: Retrieve a copy of the program

command from the address stored in

the program counter.

update the program counter to the address of the next instruction.

The instruction just Fetched is placed in the instruction register.

Page 44: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

44

DECODE: Decode the Bit pattern

in the instruction register.

EXECUTE:Having decoded the instruction, the control unit enters the execute phase. It activates the correct circuitry to perform the requested task.

Page 45: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

45

If the instruction is a load from memory, the Control unit causes the load to occur.

If the instruction is for an arithmetic operation, the control unit activates the appropriate circuitry in the ALU with the correct input stored in registers.

When the instruction has been executed, the control unit again begins the machine cycle with the Fetch cmd (the address of the next cmd is in the program counter)

Page 46: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

46

Diagram of Architecture

CPU

R1

PC R2

IR R3

R4

control unit ALU

bus

Page 47: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

47

First second third

Instr. Instr. Instr.

0 1 2 3 4

95 96 97 98 99…… ..

memory

Page 48: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

48

Secondary Storage

• Mass storage devices.– Tape drives, floppy disk drives, zip disk drives, CD-

ROM drives, etc.

• Static storage( Fixed Size)

• Slower Access Speed.

• Non-volatile

Page 49: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

49

User Input / Output• Input devices:

– Keyboard, mouse, light pen, etc.

• Output devices:

– Computer screen, printer (dot matrix, ink jet or laser), etc.

Page 50: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

50

Solving Problems on Computers

Page 51: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

51

Designing Modular Solutions

• Top-down

1. Start with what you want.

2. Cut it up in parts.

3. If the parts are trivial to solve, then solve them.

4. If the parts are non trivial, apply top-down again.

You will cut up the problem in smaller and smaller sub-

problems until they can be solved trivially.

• Bottom-up

1. Start with what you small parts.

2. Put them together to form large parts.

3. Until you end up with the thing that you wanted.

Page 52: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

52

• Problem with top-down design:– You must know how you break the problem

up.– You need intuition to tell you that this is the

right way to divide the problem into sub-problems.

• Problem with bottom-up design:– Where do you start?– Usually used in an evolution way, thus

systems start simple, functionality increases as time goes by.

Page 53: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

53

An example of Top-Down Design

Compute Tax

Compute adjustments

Compute deductions

Compute credits

Compute adjusted gross income

Compute Income

Interest &dividends

Wages Capital gains

Business income

Misc. Income

Page 54: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

54

IPOS Cycle

I – Input:

Implies 3 Questions:

1) Input what?

2) Input how?

3) Input where?

Page 55: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

55

Input What?

Program & Data

Program [Load Module] in machine code form after being compiled & Linked.

05C0 5820C00E Hexidecimal Notation

0000 0101 1100 0000 ….. Binary Notation

0 5 C 0 Hex digits

Page 56: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

56

Datae.g. Program to calculate a students avg grade

String data Numeric data

Bob 72 84

Will be stored in memory using a

Binary coding scheme:

ASCII or EBCDIC

Page 57: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

57

How Input?

Input Devices: Floppy disk, Magnetic Tape Drive, Disk Drive, CRT, Voice, Light pen, Scanners etc.

Where Input?

Main Memory of the Computer.

Page 58: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

58

Processing

2 Categories

Arithmetic: Add, subtract ,Multiply, DivideExponentiationTrig functions, etc…

Logical: Testing for relationships.

A< B; Name = ‘Mary’;C >=10; Possible Answers? (true or false)

Page 59: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

59

Output - What?

Hard copy: physical, tangible, portable.

Print outs.

Soft copy: visual, CRT displays

Output Devices: printers, floppy disk, Mag tape, Mag disk, voice, etc.

Page 60: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

60

S - Secondary Storage Medium

Long Term Storage: Disks, Tapes,

etc.

Store What? Program Itself.

Program output.

Page 61: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

61

Algorithm Representations

• Aides to documentation of your Design.

• Pseudocode: The steps of the algorithm are written in English in a shorthand form which represents the flow of control through the algorithm.

• It is not language specific.

• Its purpose is to make the logical sequence of the program clear and is an aide to writing the actual code.

Page 62: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

62

An Example: A professor who is about to write a program to assign grades to the students in his Programming in C course might express his final grade algorithm in the following pseudocode.

Repeat for each student:locate a student’s scores|

compute the average quiz score |

compute the average homework score|

if the midterm exam was a make-upthen reduce the exam score by 10%

|compute the student’s course grade

|post the student’s course grade:

Page 63: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

63

• Flowcharts:– For the problem whose solutions involve

decision and repeated steps.– Flowcharts typically show a program’s logic.– Symbols:

Start/stop Input/Output

Decisions Processing

Flow of control

Page 64: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

64

An Example : An algorithm to control an Automatic Teller Machines (ATMs).

Start

Stop

Read card

Correct pwd?

Access account info

Reject cardno

yesDeposit

Withdraw

Inquire

……

Page 65: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

65

• Decision Trees:An example: A telephone company bases its rates for long distance calls on the time of day and day of the week when a call is made.

Long distancecharges

Weekday

Weekend

8am to 5pm5pm to 11pm11pm to 8am

Saturday

Sunday

8am to 5pm5pm to 11pm11pm to 8am

full rateevening ratenight rate

night rateevening ratenight rate

night rate

Page 66: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

66

Programming

• Programming is the process of translating a problem’s solution into instructions that a computer can process.

• Software Life Cycle:– Analysis: analyze the problem.– Design: use top-down or bottom-up.– Implementation: use hardware and/or

software.– Testing: try it in the lab.– Maintenance: keep it working.

Program

ming

Page 67: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

67

• Paradigms:

– Procedural programming: • The traditional approach to the programming process.• The development of a sequence of commands that, when

followed, manipulate data to produce the desired result.• Machine languages, Fortran, Cobol, Basic, Pascal, C.

– Declarative programming:• Task is to discover and implement a general-problem solving

algorithm first.• Problems can be solved merely by stating them in a form that

is compatible with the algo, and then applying the algorithm.• It has been used for many years to simulate a

system(economic, political, environmemtal(weather)).• Prolog, GPSS.

Page 68: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

68

– Object oriented programming:

• Like procedural, but has operations on objects only.

• Operations change the state of an object.

• Eg., A list of student names is constructed as an object consisting of the list together with a collection of procedures(methods) for manipulating the list(insertions, deletions, sorting the list, detecting if the list is empty…..).

• Smalltalk, Visual basic, C++, Java.

Page 69: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

69

Part III: Computer languages

Page 70: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

70

Why Computer Languages?

• Compute are stupid.

– They do not “understand” things.– They have to be told very precisely what to do.

• Natural language are ambiguous.

– “College Station’s largest (quality (free) newspaper)”.

Page 71: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

71

High-Level Pascal Pgm

Program Example;

const x = 12;

y = 30;

var z: integer;

begin

z := x + y;

end.

Page 72: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

72

Assembly Program

EXAMPLE CSECT

Balr 12 , 0

Using Base 12

Base L 2 , X

A 2 , Y

ST 2 , Z

BCR 15 , 14

X DC F ’12’

Y DC F ’30’

Z DS F

END CSECT

Page 73: 1 INTRODUCTION TO COMPUTER SCIENCE CONCEPTS AND PROGRAMMING.

73

Machine Code( Hexidecimal)

05C0 Balr 12 , 05820 C00E L 2 , X5A20 C012 A 2 , Y5020 C016 ST 2 , Z07FE BCR 15 , 140000000C X DC F ’12’0000001E Y DC F ’30’00000000 Z DS F END EXAMPLE