2 6 arithmetic operators and the dash has two

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: . 6 Arithmetic Operators: and The dash has TWO meanings: subtraction operator (binary : uses 2 operands) Example: 30 5 negation operator (unary : uses 1 operand) Example: -4, -5 + 9 (? So what's an "operand" ?) 7 And More Assignment Operators... To avoid tedium, C has extra assignment ops: just write just write just write just write just write a += b; instead of a = a + b; a -= b; instead of a = a - b; a *= b; instead of a = a * b; a /= b; instead of a = a / b; a %= b; instead of a = a % b; 8 Precedence and Associativity (arithmetic operators) How would you evaluate the expression 17 * 8 - 2 ? Is it 17 * (8 - 2) or (17 * 8) - 2 ? These two forms give different results. We need rules! 9 Precedence and Associativity (arithmetic operators) (inner parintheses) unary minus * + / - % Higher precedence (more precedence? computed sooner) Left...
View Full Document

Ask a homework question - tutors are online