Chapter 4
Integer Expressions
In This Chapter
Declaring variables
Creating expressions
Unraveling compound expressions
Analyzing the assignment operator
Incrementing variables with the unary operator
In this chapter, get familiar with integer declarations and expressions. Ah, memories of algebra class. With any luck, it introduced you to the concepts of variables and expressions. The teacher would write something on the board like
x = 1
This equation defines a variable x and sets it equal to the value 1 until some subsequent statement changes that relationship for some reason. The term x becomes a replacement for 1. The teacher would then write the following expression:
y = 2x
Because I know that x is 1, I now know that y is equal to 2. This was a real breakthrough in the seventh grade. The good news is that all conventional computer languages follow this same pattern of creating and manipulating variables.
Declaring Variables
An integer variable declaration starts with the keyword ...
Get Beginning Programming with C++ For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.