C++ How To Program by Deitel & Deitel (2nd Edition) Computer Science
C++ HOW TO PROGRAM
SECOND EDITION
Chapter 1 Introduction to Computers and C++ Programming Chapter 2 Control Structures Chapter 3 Functions Chapter 4 Arrays Chapter 5 Pointers and Strings Chapter 6 Classes and Data Abstraction Chapter 7 Classes: Part II Chapter 8 Operator Overloading Chapter 9 Inheritance Chapter 10 Virtual Functions and Polymorphism Chapter 11 C++ Stream Input/Output Chapter 12 Templates Chapter 13 Exception Handling Chapter 14 File Processing Chapter 15Data Structures Chapter 16 Bits, Characters, Strings, and Structures Chapter 17 The Preprocessor Chapter 18 C Legacy Code Topics Chapter 19 Class string and String Stream Processing Chapter 20Standard Template Library (STL) Chapter 21 ANSI/ISO C++ Standard Language Additions
V
© Copyright 1998 by Prentice Hall. All Rights Reserved. For use only by instructors in courses for which C++ How to Program, Second Editon is the required textbook.
V
CHAPTER 1
INTRODUCTION TO COMPUTERS AND C++ PROGRAMMING
Illustrations List Fig. 1.1 Fig. 1.2 Fig. 1.3 Fig. 1.4 Fig. 1.5 Fig. 1.6 Fig. 1.7 Fig. 1.8 Fig. 1.9 Fig. 1.10 Fig. 1.11 Fig. 1.12 Fig. 1.13 Fig. 1.14 Fig. 1.15 Fig. 1.16
(Main Page)
A typical C++ environment. Text printing program. Some common escape sequences. Printing on one line with separate statements using cout. Printing on multiple lines with a single statement using cout. An addition program. A memory location showing the name and value of a variable. Memory locations after values for two variables have been input. Memory locations after a calculation. Arithmetic operators. Precedence of arithmetic operators. Order in which a second-degree polynomial is evaluated. Equality and relational operators. Using equality and relational operators. Precedence and associativity of the operators discussed so far. Using new-style header files.
© Copyright 1998 by Prentice Hall. All Rights Reserved. For use only by instructors in courses for which C++ How to Program, Second Editon is the required textbook.
Downloaded by: QuizBank (answerdone5@gmail.com)
1
CHAPTER 1
INTRODUCTION TO COMPUTERS AND C++ PROGRAMMING
Editor
Program is created in the editor and stored on disk.
Disk
Preprocessor
Compiler
Preprocessor program processes the code.
Disk
Compiler creates object code and stores it on disk.
Disk
Linker
Linker links the object code with the libraries, creates a.out and stores it on disk
Disk Primary Memory
Loader
Loader puts program in memory. . . .
Disk
Primary Memory CPU
Fig. 1.1
A typical C++ environment.
. . .
CPU takes each instruction and executes it, possibly storing new data values as the program executes.
© Copyright 1998 by Prentice Hall. All Rights Reserved. For use only by instructors in courses for which C++ How to Program, Second Editon is the required textbook.
Downloaded by: QuizBank (answerdone5@gmail.com)
2
CHAPTER 1
1 2 3 4 5 6 7 8 9 10
INTRODUCTION TO COMPUTERS AND C++ PROGRAMMING
// Fig. 1.2: fig01_02.cpp // A first program in C++ #include <iostream.h> int main() { cout << "Welcome to C++!\n"; }
return 0;
// indicate that program ended successfully
Welcome to C++!
Fig. 1.2
Text printing program.
Escape SequenceDescription
\n
Newline. Position the screen cursor to the beginning of the next line.
\t
Horizontal tab. Move the screen cursor to the next tab stop.
\r
Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line.
\a
Alert. Sound the system bell.
\\
Backslash. Used to print a backslash character.
\"
Double quote. Used to print a double quote character.
Fig. 1.3
1 2 3 4 5 6 7 8 9 10 11
Some common escape sequences.
// Fig. 1.4: fig01_04.cpp // Printing a line with multiple statements #include <iostream.h> int main() { cout << "Welcome "; cout << "to C++!\n"; }
return 0;
// indicate that program ended successfully
Welcome to C++!
Fig. 1.4
Printing on one line with separate statements using cout.
© Copyright 1998 by Prentice Hall. All Rights Reserved. For use only by instructors in courses for which C++ How to Program, Second Editon is the required textbook.
Document shared on www.docsity.com Downloaded by: QuizBank (answerdone5@gmail.com)
3