SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
Relational and Logical Operators

       www.eshikshak.co.in
Relational Operators
● Compare two values
 Result
 1                     True
 0                     False

● Six Operators, No space between the operator
 Operator              Meaning
 ==                    Equal to
 !=                    Not Equal to
 <                     Less than
 >                     Greater than
 <=                    Less than or equal to
 >=                    Greater than or equal to


                 www.eshikshak.
                     co.in
Relational Operators
● If arithmetic expression on either side of relational
  operator, than arithmetic expression will be
  evaluated first and then the results are compared.
● All of these operators are known as binary operator,
  as they required two expressions as operands.
● They are used with condition statements




                 www.eshikshak.
                     co.in
Example
● if ( value == 0 )
●{
● printf (“The value you entered was zero.n”) ;
● printf(“Please try again.n”) ;
●}
● else
●{
● printf (“Value = %d.n”, value) ;
●}




                  www.eshikshak.
                      co.in
Relational Operators
Expression     Meaning                         Result

5 == 3         5 is equal to 3                 0

5 != 3         5 is not equal to 3             1

5>3            5 is greater than 3             1

5<3            5 is less than 3                0

               5 is greater than or equal to
5 >= 3                                         1
               3

5 <= 3         5 is less than or equal to 3    0



                  www.eshikshak.
                      co.in
Logical Operator
● Sometimes we need to test multiple
  conditions in order to make a decision.
● Logical operators are used for combining
  simple conditions to make complex
  conditions.




              www.eshikshak.
                  co.in
Logical Operator


Operator          Meaning


&&                AND


||                OR


!                 NOT




            www.eshikshak.
                co.in
&& (Logical AND)


● (expression1 && expression2)
● expression1     expression2   Overall Result

  True            True          True
  (non-zero)      (non-zero)    (non-zero)
  True            False         False
  (non-zero)      (zero)        (zero)
  False           True          False
  (zero)          (non-zero)    (zero)
  False           False         False
  (zero)          (zero)        (zero)


                  www.eshikshak.
                      co.in
&& (Logical AND)


         Expression                    Result


A = ( 5 != 4 ) && ( 3 + 6 == 9 )       A=1


A = ( 5 == 4 ) && ( 3 + 6 == 9 )       A=0


A = ( 5 == 5 ) && ( 3 + 5 == 9 )       A=0


A = ( 5 == 4 ) && ( 3 + 5 == 9 )       A=0


                      www.eshikshak.
                          co.in
|| (Logical OR)


● (expression1 || expression2)
  expression1    expression2   Overall Result

  True           True          True
  (non-zero)     (non-zero)    (non-zero)
  True           False         True
  (non-zero)     (zero)        (non-zero)
  False          True          True
  (zero)         (non-zero)    (non-zero)
  False          False         False
  (zero)         (zero)        (zero)

                www.eshikshak.
                    co.in
|| (Logical OR)


         Expression                     Result


A = ( 5 != 4 ) || ( 3 + 6 == 9 )        A=1


A = ( 5 == 4 ) || ( 3 + 6 == 9 )        A=0


A = ( 5 == 5 ) || ( 3 + 5 == 9 )        A=0


A = ( 5 == 4 ) || ( 3 + 5 == 9 )        A=1


                       www.eshikshak.
                           co.in
www.eshikshak.co.in

Mais conteúdo relacionado

Semelhante a Lecture 7 relational_and_logical_operators

Semelhante a Lecture 7 relational_and_logical_operators (6)

Chaptfffffuuer05.PPT
Chaptfffffuuer05.PPTChaptfffffuuer05.PPT
Chaptfffffuuer05.PPT
 
Javascript comparison and logical operators
Javascript comparison and logical operatorsJavascript comparison and logical operators
Javascript comparison and logical operators
 
Php
PhpPhp
Php
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Second session from learn python tutorial
Second session from learn python tutorialSecond session from learn python tutorial
Second session from learn python tutorial
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
 

Mais de eShikshak

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 

Mais de eShikshak (20)

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
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
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

Lecture 7 relational_and_logical_operators

  • 1. Relational and Logical Operators www.eshikshak.co.in
  • 2. Relational Operators ● Compare two values Result 1 True 0 False ● Six Operators, No space between the operator Operator Meaning == Equal to != Not Equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to www.eshikshak. co.in
  • 3. Relational Operators ● If arithmetic expression on either side of relational operator, than arithmetic expression will be evaluated first and then the results are compared. ● All of these operators are known as binary operator, as they required two expressions as operands. ● They are used with condition statements www.eshikshak. co.in
  • 4. Example ● if ( value == 0 ) ●{ ● printf (“The value you entered was zero.n”) ; ● printf(“Please try again.n”) ; ●} ● else ●{ ● printf (“Value = %d.n”, value) ; ●} www.eshikshak. co.in
  • 5. Relational Operators Expression Meaning Result 5 == 3 5 is equal to 3 0 5 != 3 5 is not equal to 3 1 5>3 5 is greater than 3 1 5<3 5 is less than 3 0 5 is greater than or equal to 5 >= 3 1 3 5 <= 3 5 is less than or equal to 3 0 www.eshikshak. co.in
  • 6. Logical Operator ● Sometimes we need to test multiple conditions in order to make a decision. ● Logical operators are used for combining simple conditions to make complex conditions. www.eshikshak. co.in
  • 7. Logical Operator Operator Meaning && AND || OR ! NOT www.eshikshak. co.in
  • 8. && (Logical AND) ● (expression1 && expression2) ● expression1 expression2 Overall Result True True True (non-zero) (non-zero) (non-zero) True False False (non-zero) (zero) (zero) False True False (zero) (non-zero) (zero) False False False (zero) (zero) (zero) www.eshikshak. co.in
  • 9. && (Logical AND) Expression Result A = ( 5 != 4 ) && ( 3 + 6 == 9 ) A=1 A = ( 5 == 4 ) && ( 3 + 6 == 9 ) A=0 A = ( 5 == 5 ) && ( 3 + 5 == 9 ) A=0 A = ( 5 == 4 ) && ( 3 + 5 == 9 ) A=0 www.eshikshak. co.in
  • 10. || (Logical OR) ● (expression1 || expression2) expression1 expression2 Overall Result True True True (non-zero) (non-zero) (non-zero) True False True (non-zero) (zero) (non-zero) False True True (zero) (non-zero) (non-zero) False False False (zero) (zero) (zero) www.eshikshak. co.in
  • 11. || (Logical OR) Expression Result A = ( 5 != 4 ) || ( 3 + 6 == 9 ) A=1 A = ( 5 == 4 ) || ( 3 + 6 == 9 ) A=0 A = ( 5 == 5 ) || ( 3 + 5 == 9 ) A=0 A = ( 5 == 4 ) || ( 3 + 5 == 9 ) A=1 www.eshikshak. co.in