CPP
By Santosh Tawde
Chapter 1
C++ Basics
Copyright © 2008 Pearson Addison-Wesley. All rights reserved
Learning Objectives
1-3
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Introduction to C++
1-4
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Display 1.1 �A Sample C++ Program (1 of 2)
1-5
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Display 1.1 �A Sample C++ Program (2 of 2)
1-6
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
C++ Variables
1-7
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Data Types: �Display 1.2 Simple Types (1 of 2)
1-8
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Data Types: �Display 1.2 Simple Types (2 of 2)
1-9
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Assigning Data
1-10
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Assigning Data: Shorthand Notations
1-11
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Data Assignment Rules
1-12
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Literal Data
1-13
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Escape Sequences
1-14
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Display 1.3 �Some Escape Sequences (1 of 2)
1-15
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Display 1.3 �Some Escape Sequences (2 of 2)
1-16
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Constants
1-17
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Arithmetic Operators:�Display 1.4 Named Constant (1 of 2)
1-18
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Arithmetic Operators:�Display 1.4 Named Constant (2 of 2)
1-19
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Arithmetic Precision
1-20
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Arithmetic Precision Examples
1-21
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Individual Arithmetic Precision
1-22
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Type Casting
1-23
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Type Casting
1-24
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Shorthand Operators
1-25
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Shorthand Operators: Two Options
1-26
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Post-Increment in Action
1-27
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Pre-Increment in Action
1-28
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Console Input/Output
1-29
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Console Output
1-30
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Separating Lines of Output
cout << "Hello World\n";
cout << "Hello World" << endl;
1-31
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Formatting Output
1-32
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Formatting Numbers
1-33
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Error Output
1-34
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Input Using cin
1-35
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Prompting for Input: cin and cout
�Enter number of dragons: ____
1-36
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Program Style
1-37
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Libraries
1-38
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Namespaces
1-39
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Summary 1
1-40
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Summary 2
1-41
Copyright © 2008 Pearson Addison-Wesley. All rights reserved.