Chapter 4

Integer Expressions

In This Chapter

arrow Declaring variables

arrow Creating expressions

arrow Unraveling compound expressions

arrow Analyzing the assignment operator

arrow 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.