Additional Operator_Format

Additional Operator_Format - AdditionalOperators and...

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

View Full Document Right Arrow Icon
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
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
++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 ;  x = x + 1;  After the second statement  y  is  5  and  x  is  6 ? 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
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 a /= ++x + y++;  a=a/(++x + y++); 1 2 2 ++x; a = a /(x+y) ; y++;
Background image of page 4
System Mathematical Functions 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 - AdditionalOperators and...

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