Top Banner
COMPUTER PROGRAMS AND LANGUAGES Chapter 4
25

computer Programs and Languages

Feb 22, 2016

Download

Documents

verne

Chapter 4. computer Programs and Languages. Developing a computer program. Programs are a set (series) of instructions Programmers determine The instructions to be performed. The order in which those instructions are to be performed. The data required to perform those instructions. - PowerPoint PPT Presentation
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: computer Programs and Languages

COMPUTER PROGRAMS AND LANGUAGES

Chapter 4

Page 2: computer Programs and Languages
Page 3: computer Programs and Languages

Developing a computer programPrograms are a set (series) of instructions

Programmers determine• The instructions to be performed.• The order in which those instructions

are to be performed.• The data required to perform those

instructions.

Page 4: computer Programs and Languages

Program Development- Where to start?

Page 5: computer Programs and Languages

Algorithms The most basic tools that are used to

develop the problem-solving logic• steps are unambiguous • a finite number of steps

• that repeat (iterate) • require decisions (logic and comparison) until

the task is completed

Different algorithms may accomplish the same task, with a different set of instructions, in more or less the same time, space, and efforts.

Page 6: computer Programs and Languages

Example-

Page 7: computer Programs and Languages

FlowchartsA pictorial representation of an algorithm • steps in the form of different shapes of

boxes • logical flow (sequence) by

interconnecting arrows• help the programmer in understanding

the logic of the program• Flowcharts outline the general

procedure

• Comparable to blueprint of a building• draws a flowchart prior to writing a program• standard flowchart symbols prescribed by

the American National Standard Institute (ANSI).

Page 8: computer Programs and Languages
Page 9: computer Programs and Languages
Page 10: computer Programs and Languages
Page 11: computer Programs and Languages

Multiplication by addition4 x 200

200200200200

Page 12: computer Programs and Languages

Even/Odd number

Page 13: computer Programs and Languages

Calculate factorial- 5! = 5*4*3*2*1

Page 14: computer Programs and Languages

Computer languagesNatural languages are ambiguous, vaguely

structured (vs. well defined), and has very large and ever changing (vs. well defined and a stable set) vocabularies

• Machine language (Low level )• Difficult to understand

• Assembly language (Low level )• Symbolic instructions of executable machine

codes• High level language

• Some rules similar to spoken

Page 15: computer Programs and Languages

Evolution• Programming languages have evolved

tremendously• hundreds of different languages• user-friendly and more powerful• five generations

First Generation: Machine/Native Language

• Binary- every instruction and data using 0/1

• Instruction consists of two parts • Operation & Operand- where to find or store

the data (operation)• Fast and efficient, executed directly on the

CPU• Difficult for humans to read, write, and

debug

Page 16: computer Programs and Languages

Evolution …Second generation- Assembly Language• Programs can be written symbolically, using

English words (also known as mnemonics)

LDA 10 copy the contents of location 10 into the accumulator

ADD 11 add contents of location 11 to accumulator ADD 12 add contents of location 12 to accumulator STA 13 copy contents of accumulator into a location 13 STP stop - no more instructions Assemble

r?

Page 17: computer Programs and Languages

Evolution …Third Generation• High level, general-purpose• FORTRAN, LISP, COBOL, ALGOL• Ada, Basic, C, C++, Java, Pascal, Smalltalk

Easier for humans to read, write, debugCompiler translates into machine code before

runningInterpreter translates into machine code at

runtime

Page 18: computer Programs and Languages

Evolution …Fourth Generation• Specification languages, query languages,

report generators, application generators• Maple, Mathematica, Postscript, SPSS, SQL

Fifth Generation• Solve problems using constraints rather than

algorithms, used in Artificial Intelligence• Prolog

Page 19: computer Programs and Languages
Page 20: computer Programs and Languages

AssignmentsIOA, IA, GA, Case !@#$

Page 21: computer Programs and Languages

A = 10, B = 20, K = 5, and SALES = 10000

Page 22: computer Programs and Languages
Page 23: computer Programs and Languages
Page 24: computer Programs and Languages

A family tree of languages

Fortran

BASIC

Cobol LISP

Scheme

ML

Prolog

PL/1Algol 60

Algol 68Pascal

Modula 3Ada

C

C++

Simula

Smalltalk

Java

Dylan

Ruby

Perl

PythonC#

Page 25: computer Programs and Languages

BASIC (1964)• Developed at Dartmouth in 1960’s by Tom Kurtz, John Kemeny,

and a succession of undergraduates; first ran in 1964.• Beginner’s All-purpose Symbolic Instructional Code• Intended to introduce students in non-scientific disciplines to

computing.• Influenced by FORTRAN and ALGOL.• Major goal to simplify user interface:

• Simplicity chosen over efficiency• Time sharing over punched cards• Distinctions such as int vs real eliminated• Automatic defaults for declarations, values, arrays, output format,

etc.• Clear error messages• Students had access to computers at all times

• No universal BASIC standard: • ANSI (American National Standards Institute) is a minimal standard.• True Basic – Kemeny’s company