Summary


Many computer programs need to perform calculations. Computers, in addition to being able to store vast amounts of data, also can calculate far faster and more accurately than we can. You use arithmetic operators to harness the computers calculating ability.

C++ supports arithmetic operators for addition, subtraction, multiplication, and division. While addition, subtraction, and multiplication each have one operator, division has two. The / operator gives you the quotient , while the % (or modulus operator) gives you the remainder.

The arithmetic operators all work with whole number operands. All but the modulus operator also work with floating number operands. The addition operator also works with string operands, appending one string to another.

C++, unlike some other programming languages, does not have an exponent operator. Instead, it has a built-in function named pow which is defined in the standard library cmath.

In the next chapter, you will learn about relational and logical operators and control structures, which enable your program to take different actions depending on choices the user makes while the program is running.




C++ Demystified(c) A Self-Teaching Guide
C++ Demystified(c) A Self-Teaching Guide
ISBN: 72253703
EAN: N/A
Year: 2006
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net