Lecture2 - Beginning C for Engineers Spring 2008 Lecture 2...

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

View Full Document Right Arrow Icon
Beginning C for Engineers Spring 2008 Lecture 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
1/23/2008 RPI- csci1190 2 Review
Background image of page 2
1/23/2008 RPI- csci1190 3 Arithmetic in C C operation Arithmetic operator Algebraic expression C expression Addition + f + 7 f + 7 Subtraction - p - c p - c Multiplication * bm b * m Division / x / y or x ÷ y x / y Remainder % r mod s r % s • In C ab different than a * b • Arithmetic operators all binary • Integer division results in an integer
Background image of page 3

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

View Full DocumentRight Arrow Icon
1/23/2008 RPI- csci1190 4 Arithmetic in C (cont.) Remainder operator % 7 % 4 is 3 17 % 5 is 2 Divide by zero fatal error, nonfatal errors yields incorrect result Arithmetic expression in straight line
Background image of page 4
1/23/2008 RPI- csci1190 5 Operator Precedence Operator(s) Operation(s) Order of evaluation (precedence) ( ) Parentheses Evaluated first. If the parantheses are nested, the innermost pair is evaluated first. If same level, from left to right. * Multiplication Evaluated second. If there are several / Division they are evaluated left to right % Remainder + Addition Evaluated last. If there are several, - Subtraction they are evaluated left to right.
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 / 20

Lecture2 - Beginning C for Engineers Spring 2008 Lecture 2...

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