Sunteți pe pagina 1din 24

1/7/2013

ENGR 1200U Introduction to Programming Lecture 1 Course Overview Introduction to Computing Dr. Eyhab Al-Masri

1992-2012 by Pearson Education, Inc. & John Wiley & Sons References: Engineering Problem Solving with C++ (Etter et al.), C++ How to Program (Deitel et al.), C++ for Everyone (Horstmann)

Textbook

Engineering Problem Solving with C++


Authors: M. Etter, Jeanine A. Ingber Publisher: Prentice Hall 3rd Edition, 2012 ISBN: 0132492652

Evaluation Method

Assignments 20% Quizzes 10% Midterm Exam (Wed Feb 27) 20% Final Exam (TBD) 50%

ENGR 1200U Winter 2013 - UOIT

1/7/2013

Introduce computing and engineering problem solving, including:


A brief history of computers To learn about the architecture of computers To learn about machine languages and higher-level programming languages To compile and run your first C++ program To recognize compile-time and run-time errors

ENGR 1200U Winter 2013 - UOIT

Yes, ALL that is ONE computer! (except the people)


ENGR 1200U Winter 2013 - UOIT

1/7/2013

In 1842, Augusta Ada Byron (below) wrote the first computer program.

Early 1800s, Charles Babbage (above) designed the Analytical Engine (left) to process decimal numbers
ENGR 1200U Winter 2013 - UOIT

English mathematician Designed the Analytical Engine in the early 1800s


Performs only simple mathematical operations

Used for general purposes

Read instructions from punched cards and carried them out Punch different programs on input cards

ENGR 1200U Winter 2013 - UOIT

1/7/2013

Designed to process base ten numbers Consisted of four parts:


Storage unit (memory) Processing unit (computation unit) Input device (punched card reader) Output device (punched and printed output)

ENGR 1200U Winter 2013 - UOIT

Luigi F. Menabrea, French engineer and mathematician, described Babbages vision of a machine capable of solving any problem using:
Inputs Outputs Programs written on punch cards

Published a paper Sketch of the Analytical Engine Invented by Charges Babbage, Esq

ENGR 1200U Winter 2013 - UOIT

1/7/2013

Wrote the English translation of Menabreas Sketch of the Analytical Engine Envisioned the multidisciplinary potential of the Analytical Engine Wrote detailed instructions for performing numerical computations using the Analytical Engine

ENGR 1200U Winter 2013 - UOIT

ABC (Atanasoff Berry Computer)

Developed at Iowa State University between 1939 and 1942 by John Atanasoff and Clifford Berry

Weighed 700 pounds Executed one instruction every 15 seconds

ENGR 1200U Winter 2013 - UOIT

1/7/2013

ENIAC (Electronic Numerical Integrator And Calculator)

Developed by research team lead by John Mauchly and J. Presper Eckert during the early 1940s
Consisted of 18,000 vacuum tubes and 1500 relays Weight: 30 tons, 6000 switches, many jumper cables Consumed: 140 kilowatts of power

Executed hundreds of instructions every second


ENGR 1200U Winter 2013 - UOIT

ENIAC executes hundreds of operations per second (30 tons) Todays processors execute trillions of operations per second and weigh ounces.
ENGR 1200U Winter 2013 - UOIT

1/7/2013

Advances of the digital computer has facilitated many significant engineering achievements over the past five decades
Achievements illustrate how engineering has improved our lives and expanded possibilities of the future

ENGR 1200U Winter 2013 - UOIT

Some of the major achievements


Exploration of space
1996: Mars Global Surveyor: a spacecraft developed by NASA for collecting scientific data while in orbit

Application Satellites

Used to provide weather information, relay communication signals, maps, and environmental updates Example: GPS Allow for experimentation that may not be possible (due to size, speed, dangers to health and safety, etc)

Computer Simulations

ENGR 1200U Winter 2013 - UOIT

1/7/2013

You have probably used a computer for study, work or fun Many people use computers for everyday tasks such as electronic banking or writing a term paper Computers are good for such tasks C++ is a powerful computer programming language thats appropriate for technically oriented people to use in building substantial information systems

ENGR 1200U Winter 2013 - UOIT

In use today are more than a billion generalpurpose computers and billions more cell phones, smartphones and handheld devices (such as tablet computers) The number of mobile Internet users will reach approximately 134 million by 2013

ENGR 1200U Winter 2013 - UOIT

1/7/2013

By 2014, the smartphone applications market is expected to exceed $40 billion, which is creating significant opportunities for programming mobile applications Studies have projected smartphone sales to surpass personal computer sales in 2011 and tablet sales to account for over 20% of all personal computer sales by 2015

ENGR 1200U Winter 2013 - UOIT

Computing in Industry and Research

ENGR 1200U Winter 2013 - UOIT

1/7/2013

Computers can carry out a wide range of tasks because they execute different programs, each of which directs the computer to work on a specific task The computer itself is a machine that stores data (numbers, words, pictures), interacts with devices (the monitor, the sound system, the printer), and executes programs

ENGR 1200U Winter 2013 - UOIT

A computer program tells a computer, in minute detail, the sequence of steps that are needed to fulfill a task Hardware The physical computer and peripheral devices are collectively called the hardware Software The programs the computer executes are called the software

ENGR 1200U Winter 2013 - UOIT

10

1/7/2013

Programming

is the act of designing and implementing computer programs


The user is the human using a program that a programmer wrote

ENGR 1200U Winter 2013 - UOIT

ENGR 1200U Winter 2013 - UOIT

11

1/7/2013

In 1946, John von Neumann proposed a computing model that is still used today in the design of most digital computers

The von Neumann Computing Model


ENGR 1200U Winter 2013 - UOIT

The CPU (central processing unit)

heart of the computer executes one operation at a time performs program control and data processing

ENGR 1200U Winter 2013 - UOIT

12

1/7/2013

The CPU

carries out arithmetic operations such as addition, subtraction, multiplication, and division fetches data from external memory or devices and stores data back

All data must travel through the CPU whenever it is moved from one location to another

ENGR 1200U Winter 2013 - UOIT

Arithmetic Logic Unit


Performs arithmetic and logic operations ALU is a fundamental block for CPU of a computer All CPUs and Graphical Processing Units (GPUs) all have complex ALUs
Accumulator: used for temporary storage of values and results

ENGR 1200U Winter 2013 - UOIT

13

1/7/2013

The computer stores data and programs in memory


Primary memory - memory chips
Random access memory (RAM) (read-write memory) Read-only memory (ROM)

Secondary storage devices


Disk drives DVDs

ENGR 1200U Winter 2013 - UOIT

Controls the transfer and processing of data Retrieves and interprets instructions stored in memory Accepts data from an input device (i.e. keyboard or mouse), Sends data to a specified output device (i.e. printer or display) Stores data in the memory unit

ENGR 1200U Winter 2013 - UOIT

14

1/7/2013

The computer transmits information (called output) to the user through a display screen, speakers, and printers The user can enter information (called input) for the computer by using a keyboard or a pointing device such as a mouse

ENGR 1200U Winter 2013 - UOIT

Computer software contains the instructions or commands that we want the computer to perform There are several categories of software (right)
1. 2. 3.

Operating Systems Application Software Computer Languages

ENGR 1200U Winter 2013 - UOIT

15

1/7/2013

Operating Systems typically comes with the computer hardware when purchased OS provides an interface between the user and the hardware (allows user to select and execute software) OS contain a group of programs called utilities that allow the user to perform functions such as printing files, copying files, etc OS simplify the interface with the OS by using icons and menus (Examples: Windows)

ENGR 1200U Winter 2013 - UOIT

Common Applications

Database management software Computer Aided Design (CAD)

Purpose: Perform common operations Examples: word processors, text editors, spreadsheet Purpose: Efficiently store and retrieve larges amounts of data Examples: MySQL, Oracle, Microsoft SQL Purpose: Define objects and manipulate them graphically Examples: AutoCAD, Architectural Desktop, Civil 3D which Purpose: Powerful mathematical commands & generate graphs Examples: Matlab, Mathematica, Maple

Mathematical Computation Software

ENGR 1200U Winter 2013 - UOIT

16

1/7/2013

Computer languages can be described in terms of levels Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps. These may be divided into three general types: Machine languages Assembly languages High-level languages

ENGR 1200U Winter 2013 - UOIT

Low-level languages (or machine languages)

Most primitive and are tied closely to the design of the hardware (instructions are encoded) Generally consist of strings of numbers (ultimately reduced to 1s and 0s) Machine dependenta particular machine language can be used on only one type of computer Machine language differs from one machine to another (i.e. Sun versus HP computer)

ENGR 1200U Winter 2013 - UOIT

17

1/7/2013

Assembly language

Instructions are written in symbolic statements instead of binary Also unique to a specific computer design Usually have limited set of statements

Makes task of writing programs very tedious

Translator programs called assemblers convert assembly-language programs to machine language

ENGR 1200U Winter 2013 - UOIT

High-level language

Have English-like commands and instructions Examples: C, C++, Java, VB.NET, C#, etc Independent of the processor type and hardware Writing programs in high-level language is much easier that machine or assembly Contain large number of commands and an extensive set of syntax (or grammar) rules

ENGR 1200U Winter 2013 - UOIT

18

1/7/2013

Computers only understand machine language High-level languages like C++ must be translated to machine language for execution
Compiler
A special computer program that translates higher-level programs into machine instructions for a particular processor

ENGR 1200U Winter 2013 - UOIT

Source Program Object Program

printable/Readable Program file nonprintable machine readable file nonprintable executable code

Executable Program

ENGR 1200U Winter 2013 - UOIT

19

1/7/2013

Syntax/Parse Errors

Mistakes with the language Always reported by the compiler

Linking Errors

Missing pieces prevent the final assembly of an executable program

Run-time Errors

Occur when program is executing May or may not be reported

ENGR 1200U Winter 2013 - UOIT

Can be difficult to find Debugging can be time consuming


Better tools for finding bugs

It is important to carefully check the output of your programs for errors


Even programs that appear to work correctly may have bugs!

ENGR 1200U Winter 2013 - UOIT

20

1/7/2013

Process of eliminating logic errors (i.e. bugs) from programs User-friendly programming environments such as Microsoft Visual C++ integrate the compiler with

text processors and code editors special tools to help find bugs in programs (debugger) testing tools and much more

ENGR 1200U Winter 2013 - UOIT

You will need to know how to log in (if needed), and, how to start your C++ development environment An IDE (integrated development environment) is where you will most likely work

ENGR 1200U Winter 2013 - UOIT

21

1/7/2013

You will become a typist because you will use an editor to type your C++ programs into the IDE Your program is called a source program (file)

ENGR 1200U Winter 2013 - UOIT

You will need to learn how to compile and run your program in the IDE

Theres a lot going on behind the scenes in the IDE that you dont normally see

ENGR 1200U Winter 2013 - UOIT

22

1/7/2013

The compiler translates C++ programs into machine code

The linker combines machine code with library code into an executable program

ENGR 1200U Winter 2013 - UOIT

ENGR 1200U Winter 2013 - UOIT

23

1/7/2013

You will need to know your computers file system: files, folders, and extensions C++ program files typically have the extension: .cpp (or .cc or .cxx or even .C) You should be organized by creating folders for organizing your files

ENGR 1200U Winter 2013 - UOIT

You can use any of the following IDEs:


Microsoft Visual Studio (C++) NetBeans Eclipse Dev C++ CodeLite

ENGR 1200U Winter 2013 - UOIT

24

S-ar putea să vă placă și