Upload
sunnyopg
View
49
Download
6
Tags:
Embed Size (px)
DESCRIPTION
intro to programming lecture 1
Citation preview
1/7/2013
1
©1992-2012 by Pearson Education, Inc. & John Wiley & SonsReferences: Engineering Problem Solving with C++ (Etter et al.), C++ How to Program (Deitel et al.), C++ for Everyone (Horstmann)
ENGR 1200U Introduction to Programming
Lecture 1 Course Overview
Introduction to Computing
Dr. Eyhab Al-Masri
ENGR 1200UWinter 2013 - UOIT
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%
1/7/2013
2
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Yes, ALL that is ONE computer!(except the people)
1/7/2013
3
ENGR 1200UWinter 2013 - UOIT
Early 1800s, Charles Babbage (above)
designed the Analytical Engine (left) to process
decimal numbers
In 1842, Augusta Ada Byron (below) wrote the first computer program.
ENGR 1200UWinter 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
1/7/2013
4
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Luigi F. Menabrea, French engineer and mathematician, described Babbage’s 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”
1/7/2013
5
ENGR 1200UWinter 2013 - UOIT
Wrote the English translation of Menabrea’s 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 1200UWinter 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
1/7/2013
6
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
ENIAC executes hundreds of operations per second (30 tons)
Today’s processors execute trillions of operations per second and weigh ounces.
1/7/2013
7
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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
◦ Computer Simulations Allow for experimentation that may not be possible (due to
size, speed, dangers to health and safety, etc…)
1/7/2013
8
ENGR 1200UWinter 2013 - UOIT
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 that’s appropriate for technically oriented people to use in building substantial information systems
ENGR 1200UWinter 2013 - UOIT
In use today are more than a billion general-purpose 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
1/7/2013
9
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Computing in Industry and Research
1/7/2013
10
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
A computer program tells a computer, in minute detail, the sequence of steps that are needed to fulfill a task
HardwareThe physical computer and peripheral devices
are collectively called the hardware
SoftwareThe programs the computer executes are
called the software
1/7/2013
11
ENGR 1200UWinter 2013 - UOIT
Programming
is the act of designing andimplementing computer programs
The user is the human using a program that a programmer wrote
ENGR 1200UWinter 2013 - UOIT
1/7/2013
12
ENGR 1200UWinter 2013 - UOIT
The von Neumann Computing Model
In 1946, John von Neumann proposed a computing model that is still used today in the design of most digital computers
ENGR 1200UWinter 2013 - UOIT
The CPU (central processing unit)◦ heart of the computer◦ executes one operation at a time◦ performs program control and data processing
1/7/2013
13
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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
1/7/2013
14
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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
1/7/2013
15
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Computer software contains the instructions or commands that we want the computer to perform
There are several categories of software (right)
1. Operating Systems2. Application Software3. Computer Languages
1/7/2013
16
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Common Applications◦ Purpose: Perform common operations◦ Examples: word processors, text editors, spreadsheet
Database management software◦ Purpose: Efficiently store and retrieve larges amounts of data◦ Examples: MySQL, Oracle, Microsoft SQL
Computer Aided Design (CAD)◦ Purpose: Define objects and manipulate them graphically◦ Examples: AutoCAD, Architectural Desktop, Civil 3D which
Mathematical Computation Software◦ Purpose: Powerful mathematical commands & generate graphs◦ Examples: Matlab, Mathematica, Maple
1/7/2013
17
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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 dependent—a 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)
1/7/2013
18
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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
1/7/2013
19
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
Source Program◦ printable/Readable Program file
Object Program◦ nonprintable machine readable file
Executable Program◦ nonprintable executable code
1/7/2013
20
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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!
1/7/2013
21
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 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
1/7/2013
22
ENGR 1200UWinter 2013 - UOIT
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 1200UWinter 2013 - UOIT
You will need to learn how to compile and run your program in the IDE
There’s a lot going on behind the
scenes in the IDE that you don’t normally see
1/7/2013
23
ENGR 1200UWinter 2013 - UOIT
The compiler translates C++ programs into machine code
The linker combines machine code with library code into an executable program
ENGR 1200UWinter 2013 - UOIT
1/7/2013
24
ENGR 1200UWinter 2013 - UOIT
You will need to know your computer’s 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 organizingyour files
ENGR 1200UWinter 2013 - UOIT
You can use any of the following IDEs:
Microsoft Visual Studio (C++)
NetBeans
Eclipse
Dev C++
CodeLite