the other operand Float double long double float double long double double

# The other operand float double long double float

This preview shows page 31 - 38 out of 38 pages.

the other operand. Float double long double float double long double double double long double Long double long double long double float double long double This ruler can be represented in following table Note No exponentiation operator Operators are overloaded to work with more than one type of object
Integer Division Integer Division Define the integer division by (a/b)*b + a%b (a/b)*b + a%b a (b a (b 0) 0) Integer division produces an integer result Truncates the result Examples 3/2 evaluates to 1 4/6 evaluates to 0 10/3 evaluates to 3
Mod Mod Produces the remainder of the division Examples 5 % 2 evaluates to 1 12 % 4 evaluates to 0 4 % 5 evaluates to 4 When operands are negative the sign of result of modulus expression is compiler dependant. In Microsoft C++, the result of a modulus expression is always the same as the sign of the first operand. For instance, 5%(-2) evaluates to 1 -5%2 evaluates to -1 (-5)%(-2) evaluates to -1
Unary Arithmetic Operators Unary Arithmetic Operators +35, -40, -a Mixed Mixed - - mode expression mode expression Usual arithmetic conversion for mixed-mode expression int int long float double long float double long double long double int long float double long double Long long float double long double float float float double long double int int long long float float double double long double long double long double long double long double long double long double double double double double long double
Precedence and Precedence and Associativity Associativity Consider m*x + b which of the following is it equivalent to (m * x) + b m * (x + b) Operator precedence tells how to evaluate expressions Standard precedence order () Evaluate first, if nested innermost done first * / % Evaluate second. If there are several, then evaluate from left-to-right + - Evaluate third. If there are several, then evaluate from left-to-right Left associativity and Right associativity
Defining and Initializing Defining and Initializing When an object is defined using the basic form, the memory allotted to it contains random information Better idea to specify its desired value at the time of definition Exception is when the next statement is an extraction for the object Remember our convention of one definition per statement! Compute average velocity of a car
Home works Home works Page98, Exercises 2.10 Page99, Exercises 2.17 + 2.18 Page102, Exercises 2.33 Page102, Exercises 2.34
End of Chapter 2 End of Chapter 2

#### You've reached the end of your free preview.

Want to read all 38 pages?

Stuck? We have tutors online 24/7 who can help you get unstuck.
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes