11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3Performing MathematicalOperationsIn This Chapter Defining mathematical operators in C++ Using the C++ mathematical operators Identifying expressions Increasing clarity with special mathematical operatorsAmathematician uses more than just the variables described in Chapter2. A mathematician must do something with those variables: She canadd them together, subtract them, multiply them, and perform an almost endlesslist of other operations.C++ offers the same set of basic operations: C++ programs can multiply, add,divide, and so forth. Programs have to be able to perform these operations inorder to get anything done. What good is an insurance program if it can’t calculatehow much you’re supposed to (over) pay?C++ operations look like the arithmetic operations you would perform on apiece of paper, except you have to declare any variables before you can usethem (as detailed in Chapter 2):int var1;int var2 = 1;var1 = 2 * var2;Two variables, var1 and var2, are declared. var2 is initialized to 1. var1 isassigned the value resulting from the calculation two times the value of var2.This chapter describes the complete set of C++ mathematical operators.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!