SlideShare a Scribd company logo
1 of 11
Muhammad Shahbaz
Shabbir
NAWAB DEVELOPERS
An operator is a symbol that tells the
compiler to perform specific
mathematical or logical functions.
Example:-
|| , ! , && , + , = etc.
Types
•Arithmetic
•Relational <, >, <=, >=, = , !=
•Logical NOT, AND, OR
•Assignment = , +=, -=, *=, /= , %=
•Auto Increment / Decrement (or unary) --,
++
•Conditional ?:
•Comma ,
•Size of
•Bitwise
Operato
r
Description Exampl
e
&& Called Logical AND operator. If both the operands
are non-zero, then the condition becomes true.
(A && B)
is false.
|| Called Logical OR Operator. If any of the two
operands is non-zero, then the condition becomes
true.
(A || B)
is true.
! Called Logical NOT Operator. It is used to reverse
the logical state of its operand. If a condition is true,
then Logical NOT operator will make it false.
!(A &&
B) is
true.
A B AN
D
OR
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
A NOT
0 1
1 0
And &&
Or ||
Not !
Operato
r
Description Example
+ Adds two operands. A + B = 30
− Subtracts second operand from the first. A − B = -10
* Multiplies both operands. A * B = 200
/ Divides numerator by de-numerator. B / A = 2
% Modulus Operator and remainder of after
an integer division.
B % A = 0
++ Increment operator increases the integer
value by one.
A++ = 11
-- Decrement operator decreases the integer
value by one.
A-- = 9
•Rules of operator
precedence
• Operators in parentheses evaluated first
• Multiplication, division, modulus applied
next
• Addition, subtraction applied in last
• Operators applied from left to right
Operato
r
Description Example
== Checks if the values of two operands are
equal or not. If yes, then the condition
becomes true.
(A == B) is not true.
!= Checks if the values of two operands are
equal or not. If the values are not equal, then
the condition becomes true.
(A != B) is true.
> Checks if the value of left operand is greater
than the value of right operand. If yes, then
the condition becomes true.
(A > B) is not true.
< Checks if the value of left operand is less than
the value of right operand. If yes, then the
condition becomes true.
(A < B) is true.
>= Checks if the value of left operand is greater
than or equal to the value of right operand. If
yes, then the condition becomes true.
(A >= B) is not true.
<= Checks if the value of left operand is less than
or equal to the value of right operand. If yes,
(A <= B) is true.
Operato
r
Description Example
= Simple assignment operator. Assigns values
from right side operands to left side operand
C = A + B will assign the
value of A + B to C
+= Add AND assignment operator. It adds the
right operand to the left operand and assign
the result to the left operand.
C += A is equivalent to
C = C + A
-= Subtract AND assignment operator. It
subtracts the right operand from the left
operand and assigns the result to the left
operand.
C -= A is equivalent to C
= C - A
*= Multiply AND assignment operator. It
multiplies the right operand with the left
operand and assigns the result to the left
operand.
C *= A is equivalent to C
= C * A
/= Divide AND assignment operator. It divides
the left operand with the right operand and
assigns the result to the left operand.
C /= A is equivalent to C
= C / A
%= Modulus AND assignment operator. It
takes modulus using two operands and
assigns the result to the left operand.
C %= A is equivalent
to C = C % A
<<= Left shift AND assignment operator. C <<= 2 is same as C
= C << 2
>>= Right shift AND assignment operator. C >>= 2 is same as C
= C >> 2
&= Bitwise AND assignment operator. C &= 2 is same as C
= C & 2
^= Bitwise exclusive OR and assignment
operator.
C ^= 2 is same as C =
C ^ 2
|= Bitwise inclusive OR and assignment
operator.
C |= 2 is same as C =
C | 2
MUHAMMAD SHAHBAZ
SHABBIR AHMAD
C.E.O at NAWAB
DEVELOPERS

More Related Content

What's hot (18)

Operators in c++
Operators in c++Operators in c++
Operators in c++
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Python operators
Python operatorsPython operators
Python operators
 
Programming C Part 02
Programming C Part 02Programming C Part 02
Programming C Part 02
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Operators
OperatorsOperators
Operators
 
Opreator In "C"
Opreator In "C"Opreator In "C"
Opreator In "C"
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
R operators
R   operatorsR   operators
R operators
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
operator
operatoroperator
operator
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
3- Operators in Java
3- Operators in Java3- Operators in Java
3- Operators in Java
 
Comparison operators operators
Comparison operators operatorsComparison operators operators
Comparison operators operators
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
 
Operators in C#
Operators in C#Operators in C#
Operators in C#
 
Operators
OperatorsOperators
Operators
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
 

Similar to Logical Operators C/C++ language Programming

Similar to Logical Operators C/C++ language Programming (20)

itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
11operator in c#
11operator in c#11operator in c#
11operator in c#
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
Java unit1 b- Java Operators to Methods
Java  unit1 b- Java Operators to MethodsJava  unit1 b- Java Operators to Methods
Java unit1 b- Java Operators to Methods
 
Python operators part2
Python operators part2Python operators part2
Python operators part2
 
Constructor and destructors
Constructor and destructorsConstructor and destructors
Constructor and destructors
 
Computer programming 2 Lesson 7
Computer programming 2  Lesson 7Computer programming 2  Lesson 7
Computer programming 2 Lesson 7
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
 
SQL Operator.pdf
SQL Operator.pdfSQL Operator.pdf
SQL Operator.pdf
 
07 ruby operators
07 ruby operators07 ruby operators
07 ruby operators
 
Java script session 4
Java script session 4Java script session 4
Java script session 4
 
C++
C++ C++
C++
 
Relational and logical operators
Relational and logical operatorsRelational and logical operators
Relational and logical operators
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Unit 4. Operators and Expression
Unit 4. Operators and Expression  Unit 4. Operators and Expression
Unit 4. Operators and Expression
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Logical Operators C/C++ language Programming

  • 2. An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. Example:- || , ! , && , + , = etc.
  • 3. Types •Arithmetic •Relational <, >, <=, >=, = , != •Logical NOT, AND, OR •Assignment = , +=, -=, *=, /= , %= •Auto Increment / Decrement (or unary) --, ++ •Conditional ?: •Comma , •Size of •Bitwise
  • 4. Operato r Description Exampl e && Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. (A && B) is false. || Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. (A || B) is true. ! Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. !(A && B) is true.
  • 5. A B AN D OR 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 A NOT 0 1 1 0 And && Or || Not !
  • 6. Operato r Description Example + Adds two operands. A + B = 30 − Subtracts second operand from the first. A − B = -10 * Multiplies both operands. A * B = 200 / Divides numerator by de-numerator. B / A = 2 % Modulus Operator and remainder of after an integer division. B % A = 0 ++ Increment operator increases the integer value by one. A++ = 11 -- Decrement operator decreases the integer value by one. A-- = 9
  • 7. •Rules of operator precedence • Operators in parentheses evaluated first • Multiplication, division, modulus applied next • Addition, subtraction applied in last • Operators applied from left to right
  • 8. Operato r Description Example == Checks if the values of two operands are equal or not. If yes, then the condition becomes true. (A == B) is not true. != Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. (A != B) is true. > Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. (A > B) is not true. < Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. (A < B) is true. >= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true. (A >= B) is not true. <= Checks if the value of left operand is less than or equal to the value of right operand. If yes, (A <= B) is true.
  • 9. Operato r Description Example = Simple assignment operator. Assigns values from right side operands to left side operand C = A + B will assign the value of A + B to C += Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand. C += A is equivalent to C = C + A -= Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. C -= A is equivalent to C = C - A *= Multiply AND assignment operator. It multiplies the right operand with the left operand and assigns the result to the left operand. C *= A is equivalent to C = C * A /= Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. C /= A is equivalent to C = C / A
  • 10. %= Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. C %= A is equivalent to C = C % A <<= Left shift AND assignment operator. C <<= 2 is same as C = C << 2 >>= Right shift AND assignment operator. C >>= 2 is same as C = C >> 2 &= Bitwise AND assignment operator. C &= 2 is same as C = C & 2 ^= Bitwise exclusive OR and assignment operator. C ^= 2 is same as C = C ^ 2 |= Bitwise inclusive OR and assignment operator. C |= 2 is same as C = C | 2