Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 NUTS AND BOLTS: STANDARD STUFF IN C++. Chapter 5 The C++ Arithmetic Operators –Addition+ –Subtraction– –Multiplication  –Division/ –Modulus.

Similar presentations


Presentation on theme: "Chapter 5 NUTS AND BOLTS: STANDARD STUFF IN C++. Chapter 5 The C++ Arithmetic Operators –Addition+ –Subtraction– –Multiplication  –Division/ –Modulus."— Presentation transcript:

1 Chapter 5 NUTS AND BOLTS: STANDARD STUFF IN C++

2 Chapter 5 The C++ Arithmetic Operators –Addition+ –Subtraction– –Multiplication  –Division/ –Modulus (remainder)% –Increment ++ –Decrement _ _

3 Chapter 5 Order of Precedence ( ) evaluated first, inside-out. , /, or % evaluated second, left-to-right. +,  evaluated last, left-to-right.

4 Chapter 5 Increment/Decrement If a variable is preincremented or predecremented within an expression, the variable is incremented/decremented before the expression is evaluated. On the other hand, if a variable is postincremented or postdecremented within an expression, the variable is incremented/decremented after the expression is evaluated.

5 Chapter 5 The C++ Assignment Operators –Simple assignment= –Addition/assignment += –Subtraction/assignment  = –Multiplication/assignment  = –Division/assignment /= –Modulus/assignment %=

6 Chapter 5 Conversion Functions –toascii()Converts a character to its ASCII value. –tolower()Converts a character to lowercase. –toupper()Converts a character to uppercase.

7 Chapter 5 Math Functions –abs()Returns the absolute value of the argument. –acos()Returns the arc cos of the argument (radians). –asin()Returns the arc sin of the argument (radians). –atan()Returns the arc tan of the argument(radians). –cos()Returns the cosine of the argument (radians). –hypot(a,b)Returns the hypotenuse of a right triangle. –log()Returns the natural log of the argument. –log10()Returns the base 10 log of the argument.

8 Chapter 5 Math Functions (continued) –pow(x,y)Returns x raised to the power of y. –pow10(y)Returns 10 raised to the power of y. –rand()Generates random number. –srand()Initializes the random-number generator. –sin()Returns the sine of the argument (radians). –sqrt()Returns the square root of the argument. –tan()Returns the tangent of the argument (radians).

9 Chapter 5 Trig Functions Evaluate Radians, Not Degrees –The standard trig functions in the C++ math.h header file evaluate radians, not degrees. Multiply degrees by PI/180 within the trig function argument to convert degrees to radians.

10 Chapter 5 Generating A Random Number Between 0 and 99 s rand(1); randomValue = rand() % 100;


Download ppt "Chapter 5 NUTS AND BOLTS: STANDARD STUFF IN C++. Chapter 5 The C++ Arithmetic Operators –Addition+ –Subtraction– –Multiplication  –Division/ –Modulus."

Similar presentations


Ads by Google