0% found this document useful (0 votes)
27 views37 pages

Chapter 8 Operators and Expressions

This document discusses different types of operators in programming. It explains that operators are tokens that trigger computations on variables. There are unary operators like + and - that require one operand, and binary operators like +, -, *, / that require two operands. Binary operators include arithmetic, bitwise, relational, logical, and shift operators. Assignment operators like =, +=, and -= are used to assign values. Membership operators like in and not in check if a value is present in a sequence. The document provides examples of how different operators like &, |, ^, ~, <<, >> work on binary values. It concludes with a short class test on operators.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views37 pages

Chapter 8 Operators and Expressions

This document discusses different types of operators in programming. It explains that operators are tokens that trigger computations on variables. There are unary operators like + and - that require one operand, and binary operators like +, -, *, / that require two operands. Binary operators include arithmetic, bitwise, relational, logical, and shift operators. Assignment operators like =, +=, and -= are used to assign values. Membership operators like in and not in check if a value is present in a sequence. The document provides examples of how different operators like &, |, ^, ~, <<, >> work on binary values. It concludes with a short class test on operators.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

CHAPTER - 10

OPERATORS AND EXPRESSIONS


XI
Computer Science (083)
Board : CBSE
Unit 2:
Computational Thinking and Programming
Courtesy CBSE
CHAPTER - 02
OPERATORS AND EXPRESSIONS
INTRODUCTION
OPERATORS
OPERATORS
What is an operator?
Operators are tokens that trigger some
computation when applied to a variable.

What is Unary Operator?


Unary operators are those operators that
require one operand to operate upon.

Unary Operators:
+ Unary Plus
- Unary Minus
~ Bitwise Compliment
not Logical Negation
OPERATORS

What is Binary Operator?


Binary operators are those operators that
require two operands to operate upon.

Binary Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder or Modulus
** Exponent.
// Floor Division
OPERATORS

What is Binary Operator?


Binary operators are those operators that
require two operands to operate upon.

Binary Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder or Modulus
** Exponent.
// Floor Division
OPERATORS

Bitwise Operators:

& Bitwise AND


^ Bitwise Exclusive OR
| Bitwise OR

Shift Operators:

<< Shift Left


>> Shift Right
OPERATORS

Relational Operators:

< Less than


> Greater than
<= Less than equal to
>= Greater than equal to
== Equal to
!= Not equal to
Logical Operators:
and Logical AND
or Logical OR
BINARY OPERATORS EXAMPLE
BINARY OPERATORS EXAMPLE
BINARY OPERATORS EXAMPLE

Exponent

Floor
Division
BITWISE OPERATORS EXAMPLE
BITWISE AND & EXAMPLE
BITWISE AND & OPERATOR EXAMPLE
& operator picks bits exists in both the
operands (common)

BITWISE
AND
OPERATOR
BITWISE OR | EXAMPLE
BITWISE OR | OPERATOR EXAMPLE
| operator picks bits exists in either the
operands ( any one or both )

BITWISE OR
| OPERATOR
BITWISE OR EXCLUSIVE ^ EXAMPLE
BITWISE EXCLUSIVE OR ^ OPERATOR EXAMPLE
It picks up bit if it is one operand not in both
(uncommon)

BITWISE ^
OPERATOR
SHIFT OPERATORS EXAMPLE
BITWISE ONE’s COMPLIMENT

~ OPERATOR EXAMPLE
BINARY ONE’s COMPLIMENT ~ OPERATOR EXAMPLE

It is the unary operator which has a flipping


effect.
<< BINARY LEFT SHIFT

OPERATOR EXAMPLE
BINARY << LEFT SHIFT EXAMPLE
The first operand’s value is moved left by the
number of bits specified by the second operand.
<< BINARY RIGHT SHIFT

OPERATOR EXAMPLE
BINARY >> RIGHT SHIFT EXAMPLE
The first operand’s value is moved right by the
number of bits specified by the second operand.
Assignment Operators
OPERATORS

Assignment Operators:

= Assignment Operator
*= Assign Product
/= Assign Quotient
+= Assign Sum
-= Assign Minus
%= Assign Remainder
**= Assign Exponent
//= Assign Floor Division.
DIFFERENT ASSIGNMENT

STATEMENT EXAMPLE
BINARY >> RIGHT SHIFT EXAMPLE
OPERATORS

Membership Operators:

in weather variable in sequence.


not in weather variable not in sequence
MEMBERSHIP OPERATOR

EXAMPLE
MEMBERSHIP OPERATOR EXAMPLE
CLASS TEST
CLASS TEST

Time: 40 Min Max Marks: 20

1. What is an operator? Explain 05


2. Explain bitwise operators 05

3. What is assignment statement? What are the


different types of assignment operators? 05

4. Explain membership operators 05


Thank You

You might also like