0% found this document useful (0 votes)
68 views19 pages

Com01 PPT Operatorsandconditionalstatement

The document discusses different types of operators in computer programming and Java. It describes arithmetic, assignment, comparison, logical, and bitwise operators. Arithmetic operators perform math operations, assignment operators assign and operate values, comparison operators compare values, logical operators determine logical conditions, and bitwise operators perform operations at the bit level. The document also introduces conditional statements like if, else if, else, and switch that allow code to be executed based on evaluated true or false conditions.
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)
68 views19 pages

Com01 PPT Operatorsandconditionalstatement

The document discusses different types of operators in computer programming and Java. It describes arithmetic, assignment, comparison, logical, and bitwise operators. Arithmetic operators perform math operations, assignment operators assign and operate values, comparison operators compare values, logical operators determine logical conditions, and bitwise operators perform operations at the bit level. The document also introduces conditional statements like if, else if, else, and switch that allow code to be executed based on evaluated true or false conditions.
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/ 19

OPERATORS

COMPUTER PROGRAMMING <COM01>


OPERATORS
● symbols that represent
simple computations.
● used to perform
operations on variables
and values.
JAVA
OPERATORS
● Arithmetic
● Assignment
● Comparison
● Logical
● Bitwise and Shift
ARITHMETIC
OPERATORS
● used to perform common
mathematical operations.
ARITHMETIC OPERATORS
Operator Name Description Example

+ Addition Adds together two values x+y

- Subtraction Subtracts one value from another x-y

* Multiplication Multiplies two values x*y

/ Division Divides one value by another x/y

% Modulus Returns the division remainder x%y

++ Increment Increases the value of a variable by x++


1

-- Decrement Decreases the value of a variable by x--


1
ASSIGNMENT
OPERATORS
● used to assign values to
variables while operating
the value.
ASSIGNMENT OPERATORS
Operator Example Same As

= x=5 x=5

+= x += 3 x=x+3

-= x -= 3 x=x-3

*= x *= 3 x=x*3

/= x /= 3 x=x/3

%= x %= 3 x=x%3

&= x &= 3 x=x&3

|= x |= 3 x=x|3

^= x ^= 3 x=x^3

>>= x >>= 3 x = x >> 3

<<= x <<= 3 x = x << 3


COMPARISON
OPERATORS
● used to compare two
values
● return value of a either
true or false
COMPARISON OPERATORS
Operator Name Example

== Equal to x == y

!= Not equal x != y

> Greater than x>y

< Less than x<y

>= Greater than or equal to x >= y

<= Less than or equal to x <= y


LOGICAL
OPERATORS
● used to determine the
logic between variables or
values
LOGICAL OPERATORS
Operator Name Description Example

&& Logical and Returns true if both statements x < 5 && x < 10
are true

|| Logical or Returns true if one of the x < 5 || x < 4


statements is true

! Logical not Reverse the result, returns false if !(x < 5 && x < 10)
the result is true
BITWISE
OPERATORS
● perform operations on
integer data at the
individual bit-level
BITWISE OPERATORS
Operator Description

| Bitwise OR

& Bitwise AND

^ Bitwise XOR

~ Bitwise Complement

<< Left Shift

>> Signed Right Shift

>>> Unsigned Right Shift


CONDITIONAL
STATEMENTS
COMPUTER PROGRAMMING <COM01>
CONDITIONAL
STATEMENTS
● statements which
evaluates actions in
the program and
evaluates if it's true or
false
if
Used specify a block of Java code to be executed if a condition is
true
else if
statement to specify a new condition if the first condition is
false
else
Used specify a block of Java code to be executed if a condition is
false
switch
statement selects one of many code blocks to be executed

You might also like