Introduction to C++ Programming
- 2.1 Introduction
- 2.2 First Program in C++: Printing a Line of Text
- 2.3 Modifying Our First C++ Program
- 2.4 Another C++ Program: Adding Integers
- 2.5 Memory Concepts
- 2.6 Arithmetic
- 2.7 Decision Making: Equality and Relational Operators
- 2.8 Wrap-Up
- Self-Review Exercises
- Answers to Self-Review Exercises
- Making a Difference
- What's in a name? that which we call a rose By any other name would smell as sweet.
- —William Shakespeare
- When faced with a decision, I always ask, "What would be the most fun?"
- —Peggy Walker
- High thoughts must have high language.
- One person can make a difference and every person should try.
- —John F. Kennedy
We now introduce C++ programming, which facilitates a disciplined approach to program design. Most of the C++ programs you'll study in this book process information and display results. In this chapter, we present five examples that demonstrate how your programs can display messages and obtain information from the user for processing. The first three examples simply display messages on the screen. The next obtains two numbers from a user, calculates their sum and displays the result. The accompanying discussion shows you how to perform arithmetic calculations and save their results for later use. The fifth example demonstrates decision-making by showing you how to compare two numbers, then display messages based on the comparison results. We analyze each program one line at a time to help you ease your way into C++ programming.