EE 312 CHAPTERS 4-7

# EE 312 CHAPTERS 4-7 - EE 312 CHAPTERS 4-7 CHAPTER 4...

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

EE 312 CHAPTERS 4-7 CHAPTER 4 Arithmetic operators: addition, subtraction, multiplication, division o Binary: additive and multiplicative operators because they require 2 operands +, -, *, /, % ( remainder operator) Take special care with / and %: / operator truncates the result when both operands are integers % operator requires integer operands in order to compile If either / or % are used with negative operands, result depends on implementation – can be rounded up or down (ex: -9/7 could be -1 or 2 and -9%7 could be 2 or -2) o Unary: ex: k = +1; Unary + does not even exist in Classic C – does nothing o Operator precedence: Highest: + - (unary) right associative * / % left associative Lowest: + - (binary) left associative Relational operators: perform comparisons, such as < and > Logical operators: build conditions Assignment operators: o = (simple assignment) is an operator , not a statement is right associative o Compound assignment is used for updating a value already stored in a variable o In assignment v = e, if v and e do not have the same type, value of e is converted to type of v o Lvalue represents an object stored in computer memory, not a constant or the result of a computation is required by assignment operator example: variable = lvalue, expressions such as 10 or 2 * I are not Therefore, these are all WRONG and will cause a compiler error: 12 = j; j + i = 0; -i = j; o Compound Assignment: -= , +=, *=, /=, %=

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

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

{[ snackBarMessage ]}

### Page1 / 6

EE 312 CHAPTERS 4-7 - EE 312 CHAPTERS 4-7 CHAPTER 4...

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

View Full Document
Ask a homework question - tutors are online