1
1
Introduction to Computers and Programming Language
 2006 Pearson Education, Inc. All rights reserved.
OBJECTIVES
      In this chapter you will learn: Basic hardware and software concepts. The different types of programming languages. Which programming languages are most widely used. A typical C++ program development environment. The history of the industry-standard object-oriented system modeling language, the UML.  The history of the Internet and the World Wide Web.  To test-drive C++ applications in most popular C++ environmentsGNU C++ running on Linux
 2006 Pearson Education, Inc. All rights reserved.
1.1 Introduction
 Software
 Instructions to command computer to perform actions and make decisions
 Hardware  Standardized version of C++
 United States
 American National Standards Institute (ANSI)
 Worldwide
 International Organization for Standardization (ISO)
 Structured programming  Object-oriented programming
 2006 Pearson Education, Inc. All rights reserved.
1.2 What Is a Computer?
 Computer
 Device capable of performing computations and making logical decisions
 Computer programs
 Sets of instructions that control computers processing of data  Written by people called computer programmers
 Hardware
 Various devices comprising computer
 Keyboard, screen, mouse, disks, memory, CD-ROM, processing units, etc.
 2006 Pearson Education, Inc. All rights reserved.
1.3 Computer Organization
 Six logical units of computer
 Input unit
 Receiving section  Obtains information from input devices  Keyboard, mouse, microphone, scanner, networks, etc.
 Output unit
 Shipping section  Places information processed by computer on output devices  Screen, printer, networks, etc.  Information can also be used to control other devices
 2006 Pearson Education, Inc. All rights reserved.
1.3 Computer Organization (Cont.)
 Six logical units of computer (Cont.)
 Memory unit
 Rapid access, relatively low capacity warehouse section  Retains information from input unit  Immediately available for processing  Retains processed information  Until placed on output devices  Often called memory or primary memory
 Arithmetic and logic unit (ALU)
 Manufacturing section
 Performs arithmetic calculations and logic decisions
 2006 Pearson Education, Inc. All rights reserved.
PC and its component
 2006 Pearson Education, Inc. All rights reserved.
PC and its component
 2006 Pearson Education, Inc. All rights reserved.
Midrange Server and its component
 2006 Pearson Education, Inc. All rights reserved.
10
Motherboard and Other Component
 2006 Pearson Education, Inc. All rights reserved.
11
1.3 Computer Organization (Cont.)
 Six logical units of computer (Cont.)
 Central processing unit (CPU)
 Administrative section  Coordinates and supervises other sections of computer
 Secondary storage unit
 Long-term, high-capacity warehouse section  Stores inactive programs or data  Secondary storage devices  Hard drives, CDs, DVDs  Slower to access than primary memory  Less expensive per unit than primary memory
 2006 Pearson Education, Inc. All rights reserved.
12
1.4 Early Operating Systems
 What is an OS
 Operating systems are software systems that make using computers more convenient for users, application developers and system administrators.  Operating systems provide services that allow each application to execute safely, efficiently and concurrently (i.e., in parallel) with other applications.  The software that contains the core components of the operating system is called the kernel.  Popular desktop operating systems include Linux, Windows and MacOS X.  Popular mobile operating systems used in smartphones and tablets include Googles Android, BlackBerry OS and Apples iOS (for its iPhone, iPad and iPod Touch devices).
 2006 Pearson Education, Inc. All rights reserved.
Desktop and Mobile Operating System
13
 2006 Pearson Education, Inc. All rights reserved.
14
1.5 What does an OS Do
 Process Management
 A process is an executing program. It has its code, data, a certain set of resources allowed to it, and one or more flows of execution through the code. The OS manages the allocation of resources to these processes, and also provides system calls to manage these processes.  Examples  Scheduling processing within the cpu
 Multi Tasking (jumping between processing jobs)  Handles input and outputs
 2006 Pearson Education, Inc. All rights reserved.
15
1.5 What does an OS Do
 Memory Management
 Memory must be shared between the OS and an application program. The OS must manage the allocation of memory to processes and control the memory management hardware that determines which memory locations a process may access.
 Examples
 Managing Cache memory  Managing RAM  Managing Virtual Memory
 2006 Pearson Education, Inc. All rights reserved.
16
1.5 What does an OS Do
 Device Management
 Information is sent through a computers input and output devices. Processes access these devices using the system call interface. The OS tries to manage said devices in a manner that makes them efficiently shared among all processes requiring them. A system call is a programming interface to the services provided by the OS, typically written in C/C++.  Examples
 Makes sure that the correct drivers are installed so that the computer can communicate with all the input and output devices connected to the machine/computer
 2006 Pearson Education, Inc. All rights reserved.
17
1.6 Linux Operating System
 2006 Pearson Education, Inc. All rights reserved.
18
1.6 Windows Operating System
 2006 Pearson Education, Inc. All rights reserved.
19
1.6 Mac OS Operating System
 2006 Pearson Education, Inc. All rights reserved.
20
1.7 Machine Languages, Assembly Languages and High-Level Languages  Three types of computer languages
 Machine language
 Only language computer directly understands  Natural language of computer  Defined by hardware design  Generally consist of strings of numbers  Ultimately 0s and 1s  Instruct computers to perform elementary operations  Cumbersome for humans  Example  +1300042774 +1400593419 +1200274027
 2006 Pearson Education, Inc. All rights reserved.
21
1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)  Three types of computer languages (Cont.)
 Assembly language
 English-like abbreviations representing elementary computer operations  Clearer to humans  Incomprehensible to computers  Convert to machine language by translator programs (assemblers)  Example  load basepay add overpay store grosspay
 2006 Pearson Education, Inc. All rights reserved.
22
1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
 Three types of computer languages (Cont.)
 High-level languages
 Similar to everyday English  Uses common mathematical notations  Single statements accomplish substantial tasks  Converted to machine language by translator programs (compilers)  Interpreter programs  Directly execute high-level language programs  Execute more slowly than the compiled program  Example  grossPay = basePay + overTimePay
 2006 Pearson Education, Inc. All rights reserved.
23
1.8 History of C and C++
 History of C
 Evolved from BCPL and B
 Developed by Dennis Ritchie (Bell Laboratories)
 Development language of UNIX  Hardware independent
 Can write portable programs
 ANSI and ISO standard for C published in 1990
 ANSI/ISO 9899: 1990
 2006 Pearson Education, Inc. All rights reserved.
24
1.8 History of C and C++ (Cont.)
 History of C++
 Extension of C
 Developed by Bjarne Stroustrup (Bell Laboratories) in early 1980s
 Provides new features to spruce up C  Provides capabilities for object-oriented programming
 Objects: reusable software components  Model items in the real world  Object-oriented programs  Easier to understand, correct and modify
 2006 Pearson Education, Inc. All rights reserved.
25
1.9 C++ Standard Library
 C++ programs
 Built from pieces called classes and functions
 C++ Standard Library
 Rich collections of existing classes and functions
 Reusable in new applications
 Boost C++ Library
 Developed by Open Source Community  100 over libraries
 2006 Pearson Education, Inc. All rights reserved.
26
1.10 History of Java
 Java
 Originally for intelligent consumer-electronic devices
 Designed by Sun Microsystems
 Then used for creating Web pages with dynamic content  Now also used for:
 Develop large-scale enterprise applications  Enhance World Wide Web server functionality  Provide applications for consumer devices (cell phones, etc.)
 2006 Pearson Education, Inc. All rights reserved.
27
1.11 Typical C++ Development Environment
 C++ programs normally undergo six phases
 Edit
 Programmer writes program (and stores source code on disk)
 Preprocess
 Perform certain manipulations before compilation
 Compile
 Compiler translates C++ programs into machine languages
 Link
 Link object code with missing functions and data
 Load
 Transfer executable image to memory
 Execute
 Execute the program one instruction at a time
 2006 Pearson Education, Inc. All rights reserved.
28
Fig. 1.1 | Typical C++ environment.
 2006 Pearson Education, Inc. All rights reserved.
29
1.11 Typical C++ Development Environment (Cont.)
 Input/output
 cin
 Standard input stream  Normally inputs from keyboard
 cout
 Standard output stream  Normally outputs to computer screen
 cerr
 Standard error stream  Displays error messages
 2006 Pearson Education, Inc. All rights reserved.
30
1.11 Notes About C++ and C++ How to Program, 5/e
 This book is geared toward novice programmers
 Stresses programming clarity
 Portability
 C and C++ programs can run on many different computers
 2006 Pearson Education, Inc. All rights reserved.
31
1.11 Test-Driving a C++ Application
 Running and interacting with a C++ application
 Windows XP Command Prompt
 Linux shell
 2006 Pearson Education, Inc. All rights reserved.