SlideShare uma empresa Scribd logo
1 de 22
Topic:
Logical Operators and
Conditional Operator
Presented by:
Abdul Rehman (BSSE09151014)
Three Logical Operators
1. && (Logical AND)
2. | | (Logical OR)
3. ! (Logical NOT)
Logical Operators
 In this operator, the condition is true if both
conditions are true.
if ( gender == 1 && age >= 65 )
senior++;
&& (Logical AND)
Table of Logical AND
Operand 1 Operand 2 Results
x y x&&y
0 0 0
0 Non-Zero 0
Non-Zero 0 0
Non-Zero Non-Zero 1
• Use the AND operator on the bit patterns 10011000 and 00101010.
Example
Example Program
Example
 In this operator , the program is executed if any one
of the two conditions is true.
if (semesterAvg >= 90 || finalExam >=90 )
printf("Student grade is A“);
| | (Logical OR)
Operand 1 Operand 2 Result
x y x | | y
0 0 0
0 Non-Zero 1
Non-Zero 0 1
Non-Zero Non-Zero 1
Table of Logical OR
Use the OR operator on the bit patterns 10011001
and 00101110.
Example
Example Program
Int x,y,z;
if (x<y | | x<z)
printf(“x is small”);
Example
 If a condition is true then Logical NOT operator will
make false and vice versa.
if ( !( grade == 20 ) )
printf(“hello world“);
Alternative:
if ( grade != 20 )
printf(“hello world“);
! (Logical NOT)
Operand 1 Operand 2 Result Result
x y !x !y
0 0 1 1
0 Non-Zero 1 0
Non-Zero 0 0 1
Non-Zero Non-Zero 0 0
Table of Logical NOT
Use the NOT operator on the bit pattern 10011000.
Example
Example Program
Ternary operator are used to
reduce the code the in a short
form.
Conditional
Operator
 General form is,
(expression 1 ? expression 2 : expression 3);
 Conditional operators ? and : are sometimes called
ternary operators
 if expression 1 is true, then the value returned will be
expression 2, otherwise the value returned will be
expression 3
Syntax
Nested conditional operator
(expression 1 ? expression 2 : expression 3);
Single
condition or
compound
condition
(expression 1 ? expression 2 : expression 3);
(expression 1 ? expression 2 : expression 3);
Example program
main( )
{
float sal ;
printf ("Enter the salary" ) ;
scanf ( "%f", &sal ) ;
( (sal < 40000 && sal > 25000) ? printf ( "Manager" ) :
(( sal < 25000 && sal > 15000 ) ? printf ( "Accountant") :
printf ( "Clerk" ) ));
}
Any Question???

Mais conteúdo relacionado

Mais procurados

Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..Nagendra N
 
Conditional operators
Conditional operatorsConditional operators
Conditional operatorsBU
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C Self employed
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming Kamal Acharya
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
Linear differential equation
Linear differential equationLinear differential equation
Linear differential equationPratik Sudra
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)cs19club
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTSAartiMajumdar1
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficientSanjay Singh
 

Mais procurados (20)

C tokens
C tokensC tokens
C tokens
 
Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..
 
Gray Code.pptx
Gray Code.pptxGray Code.pptx
Gray Code.pptx
 
Conditional operators
Conditional operatorsConditional operators
Conditional operators
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Relational operators
Relational operatorsRelational operators
Relational operators
 
Linear differential equation
Linear differential equationLinear differential equation
Linear differential equation
 
Bcd
BcdBcd
Bcd
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 
Linear differential equation with constant coefficient
Linear differential equation with constant coefficientLinear differential equation with constant coefficient
Linear differential equation with constant coefficient
 
Logic gates presentation
Logic gates presentationLogic gates presentation
Logic gates presentation
 

Destaque

Explore new possibilities with paperless medical documentation
Explore new possibilities with paperless medical documentationExplore new possibilities with paperless medical documentation
Explore new possibilities with paperless medical documentationRonald Peterson
 
Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Syed Arslan Rizvi
 
Lecture 6 operators
Lecture 6   operatorsLecture 6   operators
Lecture 6 operatorseShikshak
 
Abuttal of Pakistan
Abuttal of PakistanAbuttal of Pakistan
Abuttal of PakistanAbdul Rehman
 
Boolean Algebra and Logic Smiplification
Boolean Algebra and Logic SmiplificationBoolean Algebra and Logic Smiplification
Boolean Algebra and Logic Smiplificationsamantha rathnayake
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...lennartkats
 
Logical expression and logical operators
Logical expression and logical operatorsLogical expression and logical operators
Logical expression and logical operatorsSuneel Dogra
 
Introduction to digital logic
Introduction to digital logicIntroduction to digital logic
Introduction to digital logicKamal Acharya
 
Introduction To Biometrics
Introduction To BiometricsIntroduction To Biometrics
Introduction To BiometricsAbdul Rehman
 
Water Level Indicator Project Presentation
Water Level Indicator Project PresentationWater Level Indicator Project Presentation
Water Level Indicator Project PresentationAbdul Rehman
 
Normalization 1
Normalization 1Normalization 1
Normalization 1Gagan Deep
 
Difference between Rural and urban life
Difference between Rural and urban lifeDifference between Rural and urban life
Difference between Rural and urban lifeAbdul Rehman
 
IS 151 Lecture 3
IS 151 Lecture 3IS 151 Lecture 3
IS 151 Lecture 3wajanga
 
IS 139 Lecture 7
IS 139 Lecture 7IS 139 Lecture 7
IS 139 Lecture 7wajanga
 

Destaque (20)

Explore new possibilities with paperless medical documentation
Explore new possibilities with paperless medical documentationExplore new possibilities with paperless medical documentation
Explore new possibilities with paperless medical documentation
 
Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)
 
Lecture 6 operators
Lecture 6   operatorsLecture 6   operators
Lecture 6 operators
 
Abuttal of Pakistan
Abuttal of PakistanAbuttal of Pakistan
Abuttal of Pakistan
 
Operators
OperatorsOperators
Operators
 
Boolean Algebra and Logic Smiplification
Boolean Algebra and Logic SmiplificationBoolean Algebra and Logic Smiplification
Boolean Algebra and Logic Smiplification
 
Digital logic mohammed salim ch4
Digital logic mohammed salim ch4Digital logic mohammed salim ch4
Digital logic mohammed salim ch4
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
 
Logical expression and logical operators
Logical expression and logical operatorsLogical expression and logical operators
Logical expression and logical operators
 
gujju
gujjugujju
gujju
 
presentation
presentationpresentation
presentation
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Introduction to digital logic
Introduction to digital logicIntroduction to digital logic
Introduction to digital logic
 
Introduction To Biometrics
Introduction To BiometricsIntroduction To Biometrics
Introduction To Biometrics
 
Water Level Indicator Project Presentation
Water Level Indicator Project PresentationWater Level Indicator Project Presentation
Water Level Indicator Project Presentation
 
Normalization 1
Normalization 1Normalization 1
Normalization 1
 
Difference between Rural and urban life
Difference between Rural and urban lifeDifference between Rural and urban life
Difference between Rural and urban life
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
IS 151 Lecture 3
IS 151 Lecture 3IS 151 Lecture 3
IS 151 Lecture 3
 
IS 139 Lecture 7
IS 139 Lecture 7IS 139 Lecture 7
IS 139 Lecture 7
 

Semelhante a Logical and Conditional Operator In C language

Semelhante a Logical and Conditional Operator In C language (20)

Java unit 3
Java unit 3Java unit 3
Java unit 3
 
4. operators in c programming by digital wave
4. operators in  c programming by digital wave4. operators in  c programming by digital wave
4. operators in c programming by digital wave
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
Presentation on logical_operators
Presentation on logical_operatorsPresentation on logical_operators
Presentation on logical_operators
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Java - Operators
Java - OperatorsJava - Operators
Java - Operators
 
Java 2
Java 2Java 2
Java 2
 
Operators
OperatorsOperators
Operators
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
Chaptfffffuuer05.PPT
Chaptfffffuuer05.PPTChaptfffffuuer05.PPT
Chaptfffffuuer05.PPT
 
Operators in java
Operators in javaOperators in java
Operators in java
 

Último

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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 ConsultingTechSoup
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
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...christianmathematics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
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.pdfQucHHunhnh
 
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.pdfAdmir Softic
 
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
 
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
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Último (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global 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
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
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...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
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
 
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
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Logical and Conditional Operator In C language

  • 1. Topic: Logical Operators and Conditional Operator Presented by: Abdul Rehman (BSSE09151014)
  • 2. Three Logical Operators 1. && (Logical AND) 2. | | (Logical OR) 3. ! (Logical NOT) Logical Operators
  • 3.  In this operator, the condition is true if both conditions are true. if ( gender == 1 && age >= 65 ) senior++; && (Logical AND)
  • 4. Table of Logical AND Operand 1 Operand 2 Results x y x&&y 0 0 0 0 Non-Zero 0 Non-Zero 0 0 Non-Zero Non-Zero 1
  • 5. • Use the AND operator on the bit patterns 10011000 and 00101010. Example
  • 8.  In this operator , the program is executed if any one of the two conditions is true. if (semesterAvg >= 90 || finalExam >=90 ) printf("Student grade is A“); | | (Logical OR)
  • 9. Operand 1 Operand 2 Result x y x | | y 0 0 0 0 Non-Zero 1 Non-Zero 0 1 Non-Zero Non-Zero 1 Table of Logical OR
  • 10. Use the OR operator on the bit patterns 10011001 and 00101110. Example
  • 12. Int x,y,z; if (x<y | | x<z) printf(“x is small”); Example
  • 13.  If a condition is true then Logical NOT operator will make false and vice versa. if ( !( grade == 20 ) ) printf(“hello world“); Alternative: if ( grade != 20 ) printf(“hello world“); ! (Logical NOT)
  • 14. Operand 1 Operand 2 Result Result x y !x !y 0 0 1 1 0 Non-Zero 1 0 Non-Zero 0 0 1 Non-Zero Non-Zero 0 0 Table of Logical NOT
  • 15. Use the NOT operator on the bit pattern 10011000. Example
  • 17. Ternary operator are used to reduce the code the in a short form. Conditional Operator
  • 18.  General form is, (expression 1 ? expression 2 : expression 3);  Conditional operators ? and : are sometimes called ternary operators  if expression 1 is true, then the value returned will be expression 2, otherwise the value returned will be expression 3 Syntax
  • 19.
  • 20. Nested conditional operator (expression 1 ? expression 2 : expression 3); Single condition or compound condition (expression 1 ? expression 2 : expression 3); (expression 1 ? expression 2 : expression 3);
  • 21. Example program main( ) { float sal ; printf ("Enter the salary" ) ; scanf ( "%f", &sal ) ; ( (sal < 40000 && sal > 25000) ? printf ( "Manager" ) : (( sal < 25000 && sal > 15000 ) ? printf ( "Accountant") : printf ( "Clerk" ) )); }