SlideShare a Scribd company logo
Operator
Precedence
and
Associativity
• Two binary operator symbols
must never be placed side by
side. For example, 5*%6 is
invalid because two operators, *
and %, are placed next to each
other.
Operator
Precedence
and
Associativity
• Parentheses can be used to form
groupings, and all expressions
enclosed in parentheses are
evaluated first. In this way, you can
use parentheses to alter the
evaluation to any order. For example,
in the expression (6+4)/(2+3), the
6+4 and 2+3 are evaluated first to
yield 10/5. The 10/5 is then
evaluated to yield 2.
Operator
Precedence
and
Associativity
• Parentheses can be enclosed by other
parentheses. For example, the expression
(2*(3+7))/5 is valid and evaluates to 4. When
parentheses are included within
parentheses, expressions in the innermost
parentheses are always evaluated first. The
evaluation continues from innermost to
outermost parentheses until all expressions
in parentheses have been evaluated. The
number of closing parentheses, ), must
always equal the number of opening
parentheses, (, so that no unpaired sets exist.
Operator
Precedence
and
Associativity
• Parentheses can’t be used to
indicate multiplication; instead,
the multiplication operator, *,
must be used. For example, the
expression (3+4)(5+1) is invalid.
The correct expression is
(3+4)*(5+1).
Operator
Precedence
and
Associativity
Parentheses should specify logical
groupings of operands and indicate the
intended order of arithmetic operations
clearly to the compiler and
programmers. Although expressions in
parentheses are always evaluated first,
expressions containing multiple
operators, whether enclosed in
parentheses or not, are evaluated by
the priority, or precedence, of the
operators.
There are three levels of precedence:
1. P1—All negations are done first.
2. P2—Multiplication, division, and modulus operations are
computed next. Expressions containing more than one
multiplication, division, or modulus operator are evaluated
from left to right as each operator is encountered. For
example, in the expression 35/7%3*4, all operations have the
same priority, so the operations are performed from left to
right as each operator is encountered. The division is done
first, yielding the expression 5%3*4. The modulus operation,
5%3, is performed next, yielding a result of 2. Finally, the
expression 2*4 is computed to yield 8.
3. P3—Addition and subtraction are computed last.
Expressions containing more than one addition or
subtraction are evaluated from left to right as each
operator is encountered.

More Related Content

What's hot

Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
Jayant Dalvi
 
Maths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectorsMaths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectors
Jaydev Kishnani
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Use of cramer`s rule in word problem
Use of cramer`s rule in word problem Use of cramer`s rule in word problem
Use of cramer`s rule in word problem
Nadeem Uddin
 
Operators
OperatorsOperators
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Lesson02 Vectors And Matrices Slides
Lesson02   Vectors And Matrices SlidesLesson02   Vectors And Matrices Slides
Lesson02 Vectors And Matrices SlidesMatthew Leingang
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt
Noumanali748226
 
Escape sequences
Escape sequencesEscape sequences
Escape sequences
Way2itech
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
amar kakde
 
C++ Data Structure PPT.ppt
C++ Data Structure PPT.pptC++ Data Structure PPT.ppt
C++ Data Structure PPT.ppt
Mukesh Thakur
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
Darshan Patel
 
Operators in C
Operators in COperators in C
Operators in C
Simplilearn
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 ppt
aviban
 
Cat Quant Cheat Sheet
Cat Quant Cheat SheetCat Quant Cheat Sheet
Cat Quant Cheat Sheet
versabit technologies
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
Lesson 3 - matrix multiplication
Lesson 3 - matrix multiplicationLesson 3 - matrix multiplication
Lesson 3 - matrix multiplication
Jonathan Templin
 

What's hot (20)

Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 
Maths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectorsMaths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectors
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
Use of cramer`s rule in word problem
Use of cramer`s rule in word problem Use of cramer`s rule in word problem
Use of cramer`s rule in word problem
 
Operators
OperatorsOperators
Operators
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Lesson02 Vectors And Matrices Slides
Lesson02   Vectors And Matrices SlidesLesson02   Vectors And Matrices Slides
Lesson02 Vectors And Matrices Slides
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Escape sequences
Escape sequencesEscape sequences
Escape sequences
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 
C++ Data Structure PPT.ppt
C++ Data Structure PPT.pptC++ Data Structure PPT.ppt
C++ Data Structure PPT.ppt
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Operators in C
Operators in COperators in C
Operators in C
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 ppt
 
Cat Quant Cheat Sheet
Cat Quant Cheat SheetCat Quant Cheat Sheet
Cat Quant Cheat Sheet
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
 
Lesson 3 - matrix multiplication
Lesson 3 - matrix multiplicationLesson 3 - matrix multiplication
Lesson 3 - matrix multiplication
 

Viewers also liked

Activities on Operator Precedence and Associativity
Activities on Operator Precedence and AssociativityActivities on Operator Precedence and Associativity
Activities on Operator Precedence and Associativity
Nicole Ynne Estabillo
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
Akshaya Arunan
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Deepak Singh
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++Pranav Ghildiyal
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
Aakash Singh
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
Stoian Kirov
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
Online
 
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 experssionseShikshak
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
Prabhu Govind
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressionsvinay arora
 

Viewers also liked (11)

Activities on Operator Precedence and Associativity
Activities on Operator Precedence and AssociativityActivities on Operator Precedence and Associativity
Activities on Operator Precedence and Associativity
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
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
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressions
 

Similar to Operator Precedence and Associativity

Introduction to Python Values, Variables Data Types Chapter 2
Introduction to Python  Values, Variables Data Types Chapter 2Introduction to Python  Values, Variables Data Types Chapter 2
Introduction to Python Values, Variables Data Types Chapter 2
Raza Ul Mustafa
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
Praveen M Jigajinni
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++
sanya6900
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
YuvarajuCherukuri
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
Jasleen Kaur (Chandigarh University)
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
Dr.Sandhiya Ravi
 
Operators in Python Arithmetic Operators
Operators in Python Arithmetic OperatorsOperators in Python Arithmetic Operators
Operators in Python Arithmetic Operators
ramireddyobulakondar
 
Lecture 05.pptx
Lecture 05.pptxLecture 05.pptx
Lecture 05.pptx
Mohammad Hassan
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
Munazza-Mah-Jabeen
 
11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx
RodmanCajes
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
classall
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
Thesis Scientist Private Limited
 
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
teach4uin
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
umardanjumamaiwada
 
operator
operatoroperator
operator
aamirsahito
 
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
venkatapranaykumarGa
 

Similar to Operator Precedence and Associativity (20)

Introduction to Python Values, Variables Data Types Chapter 2
Introduction to Python  Values, Variables Data Types Chapter 2Introduction to Python  Values, Variables Data Types Chapter 2
Introduction to Python Values, Variables Data Types Chapter 2
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Operator precedence and associativity
Operator precedence and associativityOperator precedence and associativity
Operator precedence and associativity
 
Operators in Python Arithmetic Operators
Operators in Python Arithmetic OperatorsOperators in Python Arithmetic Operators
Operators in Python Arithmetic Operators
 
2 1 expressions
2 1  expressions2 1  expressions
2 1 expressions
 
Lecture 05.pptx
Lecture 05.pptxLecture 05.pptx
Lecture 05.pptx
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx
 
lecture4 pgdca.pptx
lecture4 pgdca.pptxlecture4 pgdca.pptx
lecture4 pgdca.pptx
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
 
Operators
OperatorsOperators
Operators
 
operator
operatoroperator
operator
 
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
9-Removal of ambiguity, precedence and associativity-26-05-2023.docx
 

More from Nicole Ynne Estabillo

Sound and Waves
Sound and WavesSound and Waves
Sound and Waves
Nicole Ynne Estabillo
 
Mirrors and Reflections
Mirrors and ReflectionsMirrors and Reflections
Mirrors and Reflections
Nicole Ynne Estabillo
 
Electromagnetic Spectrum
Electromagnetic Spectrum Electromagnetic Spectrum
Electromagnetic Spectrum
Nicole Ynne Estabillo
 
Mathematics 10 (Quarter Two)
Mathematics 10 (Quarter Two)Mathematics 10 (Quarter Two)
Mathematics 10 (Quarter Two)
Nicole Ynne Estabillo
 
Ekonomiks 10 (Unit Two)
Ekonomiks 10 (Unit Two)Ekonomiks 10 (Unit Two)
Ekonomiks 10 (Unit Two)
Nicole Ynne Estabillo
 
Electromagnetic Waves
Electromagnetic WavesElectromagnetic Waves
Electromagnetic Waves
Nicole Ynne Estabillo
 
Software Development
Software DevelopmentSoftware Development
Software Development
Nicole Ynne Estabillo
 
Operands (Modulo)
Operands (Modulo)Operands (Modulo)
Operands (Modulo)
Nicole Ynne Estabillo
 
More on Data Types (Exponential and Scientific Notations)
More on Data Types (Exponential and Scientific Notations)More on Data Types (Exponential and Scientific Notations)
More on Data Types (Exponential and Scientific Notations)
Nicole Ynne Estabillo
 
Data Types
Data TypesData Types
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
Nicole Ynne Estabillo
 
Activities on Software Development
Activities on Software DevelopmentActivities on Software Development
Activities on Software Development
Nicole Ynne Estabillo
 
Activities on Exponential and Scientific Expressions
Activities on Exponential and Scientific ExpressionsActivities on Exponential and Scientific Expressions
Activities on Exponential and Scientific Expressions
Nicole Ynne Estabillo
 
Activities on Operands
Activities on OperandsActivities on Operands
Activities on Operands
Nicole Ynne Estabillo
 

More from Nicole Ynne Estabillo (14)

Sound and Waves
Sound and WavesSound and Waves
Sound and Waves
 
Mirrors and Reflections
Mirrors and ReflectionsMirrors and Reflections
Mirrors and Reflections
 
Electromagnetic Spectrum
Electromagnetic Spectrum Electromagnetic Spectrum
Electromagnetic Spectrum
 
Mathematics 10 (Quarter Two)
Mathematics 10 (Quarter Two)Mathematics 10 (Quarter Two)
Mathematics 10 (Quarter Two)
 
Ekonomiks 10 (Unit Two)
Ekonomiks 10 (Unit Two)Ekonomiks 10 (Unit Two)
Ekonomiks 10 (Unit Two)
 
Electromagnetic Waves
Electromagnetic WavesElectromagnetic Waves
Electromagnetic Waves
 
Software Development
Software DevelopmentSoftware Development
Software Development
 
Operands (Modulo)
Operands (Modulo)Operands (Modulo)
Operands (Modulo)
 
More on Data Types (Exponential and Scientific Notations)
More on Data Types (Exponential and Scientific Notations)More on Data Types (Exponential and Scientific Notations)
More on Data Types (Exponential and Scientific Notations)
 
Data Types
Data TypesData Types
Data Types
 
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
 
Activities on Software Development
Activities on Software DevelopmentActivities on Software Development
Activities on Software Development
 
Activities on Exponential and Scientific Expressions
Activities on Exponential and Scientific ExpressionsActivities on Exponential and Scientific Expressions
Activities on Exponential and Scientific Expressions
 
Activities on Operands
Activities on OperandsActivities on Operands
Activities on Operands
 

Recently uploaded

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 

Operator Precedence and Associativity

  • 1. Operator Precedence and Associativity • Two binary operator symbols must never be placed side by side. For example, 5*%6 is invalid because two operators, * and %, are placed next to each other.
  • 2. Operator Precedence and Associativity • Parentheses can be used to form groupings, and all expressions enclosed in parentheses are evaluated first. In this way, you can use parentheses to alter the evaluation to any order. For example, in the expression (6+4)/(2+3), the 6+4 and 2+3 are evaluated first to yield 10/5. The 10/5 is then evaluated to yield 2.
  • 3. Operator Precedence and Associativity • Parentheses can be enclosed by other parentheses. For example, the expression (2*(3+7))/5 is valid and evaluates to 4. When parentheses are included within parentheses, expressions in the innermost parentheses are always evaluated first. The evaluation continues from innermost to outermost parentheses until all expressions in parentheses have been evaluated. The number of closing parentheses, ), must always equal the number of opening parentheses, (, so that no unpaired sets exist.
  • 4. Operator Precedence and Associativity • Parentheses can’t be used to indicate multiplication; instead, the multiplication operator, *, must be used. For example, the expression (3+4)(5+1) is invalid. The correct expression is (3+4)*(5+1).
  • 5. Operator Precedence and Associativity Parentheses should specify logical groupings of operands and indicate the intended order of arithmetic operations clearly to the compiler and programmers. Although expressions in parentheses are always evaluated first, expressions containing multiple operators, whether enclosed in parentheses or not, are evaluated by the priority, or precedence, of the operators.
  • 6. There are three levels of precedence: 1. P1—All negations are done first. 2. P2—Multiplication, division, and modulus operations are computed next. Expressions containing more than one multiplication, division, or modulus operator are evaluated from left to right as each operator is encountered. For example, in the expression 35/7%3*4, all operations have the same priority, so the operations are performed from left to right as each operator is encountered. The division is done first, yielding the expression 5%3*4. The modulus operation, 5%3, is performed next, yielding a result of 2. Finally, the expression 2*4 is computed to yield 8.
  • 7. 3. P3—Addition and subtraction are computed last. Expressions containing more than one addition or subtraction are evaluated from left to right as each operator is encountered.