chapter 1 getting acquainted with computers, programs, and c++
TRANSCRIPT
Chapter 1Getting Acquainted With
Computers, Programs, and C++
Chapter 1
• A Typical PC
Chapter 1
ALU
Control
Unit
Internal
Registers
CPU
Bus
Bus
Memory
I/O
Primary
Secondary
Input
Output
• The Hardware
Chapter 1
• The Central Processing Unit (CPU)The central processing unit (CPU) is the brain and nerve center of the entire system. This is where all of the calculations and decisions are made. In a PC system, the entire CPU is contained within a single integrated circuit (IC) chip called a microprocessor.
Chapter 1
Internal RegistersALU
Control Unit
CPU
Chapter 1
• Typical Operations Performed by the ALU
Addition +Subtraction Multiplication * Division / Modulus (Remainder) %Equal to == Not equal to != Less than < Less than or equal to <= Greater than > Greater than or equal to >=
Chapter 1
• Primary MemoryPrimary memory often is called main working memory. The reason for this is that primary, or main, memory is used to store programs and data while they are being “worked,” or executed, by the CPU.
Chapter 1
Binary Values
bit 0 or 1
byte 8 bits
kilobyte(KB) 1024 bytes
megabyte(MB) 1,048,576 bytes
gigabyte(GB) 1,073,741,824 bytes
Chapter 1
.
.
67,108,863
Memory Contents
64 MB RAM
10010011
Memory
(Data)Addresses
67,108,862
.
11010111
.
.
.
101101110
1
10010110
Chapter 1
• Secondary MemorySecondary memory, sometimes called bulk or mass storage, is used to hold programs and data on a semi-permanent basis. The most common types of secondary memory used in PC systems are magnetic disks and CDs.
Chapter 1
• InputInput is what goes into the system. Input devices are hardware devices that provide a means of entering programs and data into the system. The major input devices for a PC system are the keyboard, mouse, and disk drive.
Chapter 1
• OutputOutput is what comes out of the system. Output devices are hardware devices that provide a means of getting data out of the system. The four major output devices with which you will be concerned are the display monitor, printer, disk drive, and modem.
Chapter 1
Primary Memory(RAM)
Your C++Program
ProgramYour C++
Primary Memory(RAM)
"Save"
"Load"
C++
C++
File
File
(a)
(b)
• Loading and Saving Your C++ Programs
Chapter 1
• The Fetch/Execute CycleThe fetch/execute cycle is what takes place when you run a program.
Chapter 1
• The SoftwareComputer software can be likened to the driver of an automobile. Without the driver, nothing happens. In other words, the computer hardware by itself can do nothing. A set of software instructions that tells the computer what to do is called a computer program.
Chapter 1
• Machine LanguageAll of the hardware components in a computer system, including the CPU, operate on a language made up of binary 1’s and 0’s. A CPU does not understand any other language.
Chapter 1
• Assembly LanguageAssembly language employs alphabetic abbreviations called mnemonics that are easily remembered by you, the programmer. For instance, the mnemonic for addition is ADD, the mnemonic for move is MOV, and so forth.
Chapter 1
• Operating SystemsAn operating system, or OS, is the “glue” that binds the hardware to the application software. Actually, an operating system is a collection of software programs dedicated to managing the resources of the system.
Chapter 1
• High-Level LanguageA high-level language consists of instructions, or statements, that are similar to English and common mathematical notation. When programming in a high-level language, you do not have to concern yourself with the specific instruction set of the CPU. Rather, you can concentrate on solving the problem at hand.
Chapter 1
• Language TranslationA source program is the one that you write in the C++ language and that normally has a file extension of .cpp. An object program is the binary machine language program generated by the C++ compiler, which always has a file extension of .obj.
Chapter 1
Enter/edit the program
Save
Source (.
Compile
Link
Success
FailCorrect errors
Object (.
Executable (.
cpp) file
obj ) file
exe ) file
• C++ Translation
Chapter 1
• Structured vs. Object-Oriented LanguagesThe C language is a structured language that allows complex problems to be solved using a modular, top/down, approach. The C++ language contains the C language for structured programming, but in addition extends the C language to provide for object-oriented programming (OOP).
Chapter 1
• Object-oriented programming (OOP) allows complex problems to be solved using more natural objects that model the way we humans think about things.
Chapter 1• Hello World
/*
NAME: ANDREW C. STAUGAARD JR.
CLASS: CS1
PROGRAM TITLE: HELLO WORLD
DATE: 5/16/01
THIS PROGRAM WILL DISPLAY THE MESSAGE "Hello World" TO THE SYSTEM MONITOR
*/
//PREPROCESSOR SECTION
#include <iostream.h> //FOR cout
//MAIN FUNCTION SECTION
int main()
{ //BEGIN MAIN FUNCTION BLOCK
cout << "Hello World"; //DISPLAY MESSAGE TO MONITOR
return 0;
} //END MAIN FUNCTION BLOCK