{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

C By Discovery (4th Edition)

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

View Full Document Right Arrow Icon
1 Intermediate Programming CSE 1320 Lecture 02 Chapter 1: 1.6-1.7 Arithmetic Operations (integer) + (binary) addition 2 + 3 - (binary) subtraction 10 - 2 * (binary) multiplication 23 * 521 / (binary) division truncating: 2 / 3 is 0, 3 / 2 is 1, 13 / 4 is 3 portability: opposing signs: results vary according to compiler – use function abs in stdlib.h abs(-3) is 3, abs(2) is 2 % (binary) remainder a % b: remainder when a is divided by b only defined for operands of type int portability: opposing signs: results vary according to compiler – use function abs 7 % 3 is 1, 8 % 3 is 2, 9 % 5 is 4 a = (a/b)*b + (a%b) + (unary) plus no effect on its operand: +3, +x - (unary) minus changes the sign of its operand Precedence of Arithmetic Operations Unary operators: -, + Multiplicative operators: *, /, % Additive operators: +, - Assignment operator: = Operations associate from left to right a*b/c is (a*b)/c 2*a + 4/b is (2*a) + (4/b) Use parentheses for readability Compound Assignment – A single variable is changed – Used also with operations other than arithmetic
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • Sprintston
  • Function prototype declaration, Intermediate Programming CSE, type int portability, Preprocessor Constant Definition

{[ snackBarMessage ]}