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

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

View Full Document Right Arrow Icon
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: -= , +=, *=, /=, %=
Background image of page 1

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

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

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 Right Arrow Icon
Ask a homework question - tutors are online