Download presentation

Presentation is loading. Please wait.

Published bySamuel Hahn Modified over 3 years ago

1
Operators and Arithmetic Operations

2
Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands. C operators are categorized to several types: assignment operator assignment operator mathematical operators mathematical operators relational operators relational operators logical operators logical operators

3
Assignment Operator The assignment operator which is the equal sign ( = ). If you write c = y in a C program, the value of y is assigned to c. In assigning, the right side can be any expression and the left side must be a variable name.

4
Mathematical Operators C mathematical operators can be classified into two: unary and binary Binary operators Mathematical operators perform math operations such as: addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ) and modulus ( % ). addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ) and modulus ( % ).

5
Mathematical Operators Unary operators C has two unary operators: the increment and the decrement Prefix or infix = ++x for increment and - - x for decrement Postfix = x++ for increment and X - - for decrement

6
Operator Precedence An expression contains more than one operator. The order in which operations are performed pose a significance. This order is called operator precedence. Operations with higher precedence are performed first when an expression is evaluated. Operators Relative Precedence Operators Relative Precedence ++ - -1 * / %2 + -3

7
If an expression contains more than one operator with the same precedence level, the operators are performed in left to right order as they appear in the expression. C also uses parentheses to modify the evaluation order. A sub expression enclosed in parentheses is evaluated first without regard to operator precedence.

8
Relational Operators OperatorSymbolExample Equal==X==A Not equal !=A!=0 Less than

9
Logical Operators OperatorSymbolExample and&& var1 & & var2 or|| var1 | | var2 not!!var1

Similar presentations

OK

LESSON 3 Expressions, Statements, & Operators. STATEMENTS A statement Controls the sequence of execution Evaluates an expression Does nothing (the null.

LESSON 3 Expressions, Statements, & Operators. STATEMENTS A statement Controls the sequence of execution Evaluates an expression Does nothing (the null.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Download ppt on live line maintenance usa Ppt on world war 2 Ppt on historical places in hyderabad Ppt on power grid failure Ppt on anticancer therapy Ppt on role of entrepreneur in economic development Ppt on credit default swaps news By appt only movie Ppt on time management tips Ppt on catenation of carbon