Additional Operator_Format

Additional Operator_Format - Additional Operators and Click...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style 2/5/11 Additional Operators and Math functions in C++
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/5/11 Increment & Decrement Operators Increment operator: increase variable by 1 Decrement operator: decrease variable by 1 Pre-increment: ++variable Post-increment: variable++ Pre-decrement: --variable Post-decrement: variable--
Background image of page 2
2/5/11 Increment & Decrement ++count; or count++; increases the value of count by 1 --count; or count--; decreases the value of count by 1 If x = 5; and y = ++x; x y it is the same as 2 statements x = x + 1; y = x ; After the second statement both x and y are 6 If x = 5; and y = x++; it is the same as 2 statements y = x ; ? 5 6 6 5 5 6 ?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/5/11 Assignment Statements C++ has special assignment statements called compound assignment: += , -= , *= , /= , and %= Example: x y a int x = 2, = 3, a = 4 ; 2 3 4 x *= y; – & x = x * y ; 6 3 4 x += y + 2 ; – & x = x + (y + 2) ;11 3 4 x -= y; – & x = x – y ; 8 3 4 x /= y + a - 3 ; – & x = x/(y+ a - 3);2 3 4 x %= y ; – & x = x % y ; 2 3 4 x %= y -1 ; – & x = x % (y-1); 0 3 4 y /= x + 2; –& y = y / (x + 2) ; 0 1 4
Background image of page 4
2/5/11 System Mathematical Purpose Function Name Prototype/Signature Usage Notes Computes cosine cos double cos (double X); X must be in radians! Computes sine sin double sin (double X); Computes tangent tan double tan (double X); Computes arc cosine acos double acos (double X); Return value is in radians. X must lie in domain -1 to +1.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Additional Operator_Format - Additional Operators and Click...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online