Lecture 13 Arithmatic in C

Lecture 13 Arithmatic in C - Lecture13:ArithmeticinC...

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

View Full Document Right Arrow Icon
FAST, National University of Computer and Emerging Sciences, Islamabad 1 Lecture 13:  Arithmetic in C Course: Programming For Engineers-1
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
2 Reference Ch.2 of the Text Book
Background image of page 2
3 Expressions expressions  are used to express computation. Expressions include operations and the  operands  on which the  operations are applied. Operands can be variables, literals or constants. Operations are mathematical operators like (+,/,-,*.%).
Background image of page 3

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

View Full Document Right Arrow Icon
4 Arithmetic Operators Operators allowed in an expression depend upon the  data types of constants and variables in the  expression. Operand   variable or a constant on which an operator is applied is called an operand . 67 + 25   operator +, operands 67 and 25
Background image of page 4
5  Arithmetic Operators 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 x / y  Modulus r mod s r % s 
Background image of page 5

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

View Full Document Right Arrow Icon
6 Precedence and Associativity   Operators have rules of  precedence  and  associativity   that control how expressions are  evaluated. What is the value of this C expression ?: 2 / 3 / 4 + 5 Answer:  You can't tell unless you know the rules.
Background image of page 6
7 Associativity The associativity of an operator 
Background image of page 7

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

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

{[ snackBarMessage ]}

Page1 / 23

Lecture 13 Arithmatic in C - Lecture13:ArithmeticinC...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online