0% found this document useful (0 votes)
9 views4 pages

C Operators Notes

Uploaded by

ryumei1002024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

C Operators Notes

Uploaded by

ryumei1002024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

📔

RECORDED LECTURE 4 -
OPERATORS
Operators
Assignment Operator
Symbol: ‘=’

Arithmetic Operator
Multiplication - ‘*’

Division - ‘/’

Addition - ‘+’

Subtraction - ‘-’

Modulus - ‘%’

Relational Operator
Less than - ‘<’

Greater than - ‘>’

Less than or equal to - ‘<=’

Greater than or equal to - ‘>=’

Equal to - ‘==’

Not equal to - ‘!=’

Logical Operator

RECORDED LECTURE 4 - OPERATORS 1


and - ‘&&’

Truth Table: Result is true if and only if all expressions are true

Exp 1 && Exp 2 Result

T T T

T F F

F T F

F F F

or - ‘||’

Truth Table: Result is true if at least one expression is true

Exp 1 || Exp 2 Result

T T T

T F T

F T T

F F F

not - ‘!’

Truth Table: Result is the reciprocal of the expression

! Exp Result

T F

F T

Increment Operator
Symbol: ‘++’

Adds 1

Can be placed before or after a variable

If it is placed before the variable, the operation takes place before any
other

If it is placed after the variable, the operation takes place after others

RECORDED LECTURE 4 - OPERATORS 2


Examples:

1. ++A where A = 5 → A=?=6

2. A++ where A = 5 → A=?=6

3. B = 10 + ++A where A = 5 → A=?=6, B=?=16

4. B = 10 + A++ where A = 5 → A=?=6, B=?=15

Decrement Operator
Symbol: ‘—’

Subtracts 1

Can be placed before or after a variable

If it is placed before the variable, the operation takes place before any
other

If it is placed after the variable, the operation takes place after others

Examples:

1. —A where A = 5 → A=?=4

2. A— where A = 5 → A=?=4

3. B = 10 + —A where A = 5 → A=?=4, B=?=14

4. B = 10 + A— where A = 5 → A=?=4, B=?=15

Combined Operators
*=

/=

+=

-=

%=

An equation in the form of: ‘<var> = <var> <arithmetic operator> <expr>’ can
be simplified using the format: <var> <arithmetic operator> = <expr>

RECORDED LECTURE 4 - OPERATORS 3


Examples:

1. X = X*Y → X*=Y

2. X = Y*X → X*=Y

3. X = X/(Y+2) → X/=(Y+2)

4. X = X+3 → X+=3

5. X = X-1 → X-=1 or X—

RECORDED LECTURE 4 - OPERATORS 4

You might also like