Top Banner
Computer Programming I 1 TCP1231 Computer Programming I FIST Multimedia University
30

Computer Programming - Lecture 1

Nov 07, 2014

Download

Education

 
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 Programming - Lecture 1

Computer Programming I 1

TCP1231 Computer Programming I

FIST Multimedia University

Page 2: Computer Programming - Lecture 1

Computer Programming I 2

Objectives

To help students achieve a reasonable level of competence in both problem solving and writing computer programs using C++ programming language.

To encourage students to appreciate the value of adopting good programming style and taking a structured modular approach to the design of programs.

Page 3: Computer Programming - Lecture 1

Computer Programming I 3

Skills expected to be acquired

Problem solving and software development using C++ language

The use of a range of software tools and packages (compiler, development environment, debugger, word processor)

Practical skills in an operating system environment (Windows) and the use of the internet and online resources

Page 4: Computer Programming - Lecture 1

Computer Programming I 4

Course OutlineLec1 – Introduction to computing and programming

Lec2 – Algorithms and Problem Solving

Lec3 – C++ Basics (Part I)

Lec4 – C++ Basics (Part II)

Lec5 – More Flow of Control

Lec6 – Procedural Abstraction (function part 1)

Lec7 – Modular Design and functions (functions part 2)

+ Namespaces and separate compilation

Lec8 – Arrays

Lec9 – Introduction to Classes and Structures

Lec10 – Array & Strings & Vectors

Lec11 – Pointers

Lec12 – Pointers and Dynamic Arrays

Lec12 – I/O Streams and Files

Page 5: Computer Programming - Lecture 1

Computer Programming I 5

Resources Textbook

Walter Savitch, 2012, Problem Solving with C++(Eighth Edition), Addison Wesley

Reference Frank L. Friedman, “Problem Solving, Abstraction,

and Design Using C++”, Sixth Edition, Pearson Deitel, C++ How to Program(Fifth Edition), Pearson Horstmann, Budd, “Big C++”, 2nd Edition, Wiley Tony Graddis, Barret Krupnow, Starting Out with C+

+, Addison Wesley

Page 6: Computer Programming - Lecture 1

Computer Programming I 6

Integrated Development Environment (IDE)

Page 7: Computer Programming - Lecture 1

Computer Programming I 7

Lecture 1Introduction

to Computers & Programming

Page 8: Computer Programming - Lecture 1

Computer Programming I 8

Overview

Computer systems Programming languages Compiler Linker

Page 9: Computer Programming - Lecture 1

Computer Programming I 9

Computer System

A computer program is… A set of instructions for a computer to follow

Computer software is … The collection of programs used by a computer

• Includes:» Editors» Translators» System Managers

Page 10: Computer Programming - Lecture 1

Computer Programming I 10

Hardware Three main classes of computers

PCs (Personal Computer)• Relatively small used by one person at a time

Workstation• Larger and more powerful than a PC

Mainframe• Still larger• Requires support staff• Shared by multiple users

Page 11: Computer Programming - Lecture 1

Computer Programming I 11

Computer Organization

Page 12: Computer Programming - Lecture 1

Computer Programming I 12

Computer Organization Five main components

1) Input devices– Allows communication to the computer

2) Output devices– Allows communication to the user

3) Processor (CPU)

4) Main memory– Memory locations containing the running program

5) Secondary memory– Permanent record of data often on a disk

Page 13: Computer Programming - Lecture 1

Computer Programming I 13

Computer Memory

Main Memory Long list of memory locations

• Each contains zeros and ones• Can change during program execution

Binary Digit or Bit• A digit that can only be zero or one

Byte• Each memory location has eight bits

Address • Number that identifies a memory location

Page 14: Computer Programming - Lecture 1

Computer Programming I 14

Secondary Memory

Main memory stores instructions and data while a program is running.

Secondary memory Stores instructions and data between sessions A file stores data or instructions in

secondary memory

Page 15: Computer Programming - Lecture 1

Computer Programming I 15

Memory Access

Random Access Usually called RAM

• Computer can directly access any memory location

Sequential Access Data is generally found by searching through

other items first• More common in secondary memory

Page 16: Computer Programming - Lecture 1

Computer Programming I 16

The Processor

Typically called the CPU Central Processing Unit Follows program instructions Typical capabilities of CPU include:

addsubtractmultiplydividemove data from location to location

Page 17: Computer Programming - Lecture 1

Computer Programming I 17

Computer Software The operating system

Allows us to communicate with the computer Is a program Allocates the computer’s resources Responds to user requests to run other

programs

Common operating systems include… UNIX Linux DOS

Windows Macintosh VMS

Page 18: Computer Programming - Lecture 1

Computer Programming I 18

High-level Languages Common programming languages include …

C C++ Java Pascal Visual Basic FORTRAN COBOL Lisp Scheme Ada

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

Page 19: Computer Programming - Lecture 1

Computer Programming I 19

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

Page 20: Computer Programming - Lecture 1

Computer Programming I 20

Programming Languages

Various programming languages enable people to tell computers what to do

Foundation for developing applications

Page 21: Computer Programming - Lecture 1

Computer Programming I 21

Programming Languages Machine Language (first generation)

The computer’s ‘native language’ Composed of binary digits (0s, 1s)

Eg. 0110 1001 1010 1011 The only language that computers understand

Assembly Language (second generation)

One-to-one correspondence to machine language Somewhat more user-friendly than machine

language (mnemonic rather than binary digits) Eg. ADD X Y Z

Assembler – program that translates an assembly language program into machine language

Page 22: Computer Programming - Lecture 1

Computer Programming I 22

Procedural Languages (third generation)

One instruction translates into many machine language instructions

Programs describe the computer’s processing step-by-step

Closer to natural language; uses common words rather than abbreviated mnemonics

Examples: C, C++, Java, Fortran, QuickBasic Compiler - translates the entire program at once Interpreter - translates and executes one source

program statement at a time

Programming Languages

Page 23: Computer Programming - Lecture 1

Computer Programming I 23

Nonprocedural Languages (fourth generation) Allows the user to specify the desired result without

having to specify the detailed procedures needed for achieving the result

Example: – database query language - SQLCan be used by non technical users

Natural Language Programming Languages (fifth generation (intelligent) languages) Translates natural languages into a structured,

machine-readable form Are extremely complex and experimental

Programming Languages

Page 24: Computer Programming - Lecture 1

Computer Programming I 24

Object-Oriented Programming Languages (OOP) based on objects – packaging data and the

instructions about what to do with that data together Examples: Java, C++

Visual Programming Languages Used within a graphical environment Examples : Visual Basic and Visual C++ Popular to non technical users.

Current Programming Languages

Page 25: Computer Programming - Lecture 1

Computer Programming I 25

Hypertext Markup Language (HTML) standard language used in World Wide Web contains text, images, and other types of

information such as data files, audio, video, and executable computer programs

Extensible Markup Language (XML) Improved on web document functionality

Virtual Reality Modeling Language (VRML) a file format for describing three-dimensional

(3D) interactive worlds and objects can be used with the World Wide Web

Current Programming Languages

Page 26: Computer Programming - Lecture 1

Computer Programming I 26

Compilers

Translate high-level language to machine language

Source code• The original program in a high level language

Object code• The translated version in machine language

Page 27: Computer Programming - Lecture 1

Computer Programming I 27

Linkers Some programs we use are already compiled

Their object code is available for us to use For example: Input and output routines

A Linker combines The object code for the programs we write

and The object code for the pre-compiled routines

into The machine language program the CPU can run

Page 28: Computer Programming - Lecture 1

Computer Programming I 28

How are Programs Understood by the Computer?

Program written in programming language (source code)

Translator program Assembler Compiler Interpreter

Program written in machine language (object code)

Processed By CPU

The Language Translation Process

Page 29: Computer Programming - Lecture 1

Computer Programming I 29

History Note

First programmable computer Designed by Charles Babbage Began work in 1822 Not completed in Babbage’s life time

First programmer Ada Augusta, Countess of Lovelace

• Colleague of Babbage

Page 30: Computer Programming - Lecture 1

Computer Programming I 30

End