SlideShare a Scribd company logo
OPERATORS IN C
WHAT IS OPERATOR?
• C support rich set of built-in operators.
• We have already used several of them, such as + - * & = < etc.
• Operators are used in programs to manipulate data and variables.
• An operator is a symbol that perform certain mathematical or logical
manipulations.
• C operators can be classified into number of categories.
TYPES OF OPERATORS
• Arithmetic operators
• Relational operators
• Logical operators
• Assigment operators
• Increment and decrement operators
• Conditional operators
• Bitwise operators
• Special operators
ARITHMETIC OPERATORS
• C provides all the basic arithmetic operators.
• Arithmetic operators are
addition(+),Subtraction(),Multiplication(*),Division(/) and Modulo
division(%).
• For example :
a +b a-b
a*b a/b
• There are 3 types of arithmetic operator
1.Integer arithmetic(When both operands are single
arithmetic expression) ex: 5 + 5 = 10.
2.Real arithmetic(An arithmetic operation involving
only real operands ) ex : 6.0/7.0=0.857143
3.Mixed-mode arithmetic(When one of the
operands is real and the other is integer) ex: 15/10.0 = 1.5
RELATIONAL OPERATORS
• Relational operator compares two quantities depending on their
relation.
• For example : compare the age of two persons,prices of two items
and so on.
• Relational operator : Greater than(>), Greater than or equal to(>=),
Less than(<), Less than or equal to(<=), Equal to(==),Not equal to(!=).
Eg: 10 < 20
a ==b
LOGICAL OPERATORS
• Logical operator which combines two or more relational
expressions,is termed as compound logical expression.
• C has the following three logical operator.
&& - Logical AND
|| - Logical OR
! - Logical NOT
For example : if(age>55 && salary<1000)
ASSIGNMENT OPERATORS
• Assignment operators are used to assign the result of an expression
to a variable.
= -> Assignment operator
Example : a=5;
• C has a set of ‘Shorthand’ assignment operator.
v op=exp
Example : x += 3;
INCREMENT AND DECREMENT OPERATORS
• The increment operator ++ adds 1 to the operand, while the
decrement operator - - subtracts 1 to the operand.
++ - Increment operator
-- - Decrement operator
• We use the increment and decrement statements in for and while
loops.
++m; or m++;
--m; or m--;
CONDITIONAL OPERATORS
• A ternary operator pair “?:” is available in c, the conditional expression of
the form
exp1 ? exp2 : exp3
• Where exp1,exp2,exp3 are expressions.
• exp 1 is evaluated first, if it is true then exp 2 is executed.
• If exp 1 is evaluated , it is false then exp3 is executed.
a=10;
b=15;
x=(a>b)?a : b;
• It can be achieved using if…else statements.
BITWISE OPERATORS
• C has a distinction of supporting special operators known as bitwise
operator for manipulating of data at bit level.
• These operator are used for testing the bits or shifting them right or
left.
& - bitwise AND
| - bitwise OR
<<- shift left
>>-shift right
SPECIAL OPERATORS
• C supports some special operators such as comma operator , sizeof
operator.
• Comma operator : The comma operator used to link the related
expression together.
For example : for(n=1,m=10,n<=m;n++,m++);
• Sizeof operator : Sizeof operator is a compile time operator, it
returns the number of bytes the operand occupies.
For example : m=sizeof(sum);

More Related Content

Similar to OPERATORS IN C.pptx

This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
ranaashutosh531pvt
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
ANANT VYAS
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
Kaushal Patel
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
Hassan A-j
 
Csc240 -lecture_5
Csc240  -lecture_5Csc240  -lecture_5
Csc240 -lecture_5
Ainuddin Yousufzai
 
C language operators
C language operatorsC language operators
C language operators
marar hina
 
Operator in C language
Operator in C languageOperator in C language
Operator in C language
KanhaiyaSharma52
 
Cse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expressionCse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expression
FarshidKhan
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++
sanya6900
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
Online
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
Thesis Scientist Private Limited
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
rricky98
 
C++
C++ C++
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressionsvishaljot_kaur
 
intro to differnt oper.pptx
intro to differnt oper.pptxintro to differnt oper.pptx
intro to differnt oper.pptx
ssuser5ad1571
 
Operators
OperatorsOperators

Similar to OPERATORS IN C.pptx (20)

This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
 
Csc240 -lecture_5
Csc240  -lecture_5Csc240  -lecture_5
Csc240 -lecture_5
 
C language operators
C language operatorsC language operators
C language operators
 
Operator in C language
Operator in C languageOperator in C language
Operator in C language
 
Cse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expressionCse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expression
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
 
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++
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
C++
C++ C++
C++
 
Operators
OperatorsOperators
Operators
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
intro to differnt oper.pptx
intro to differnt oper.pptxintro to differnt oper.pptx
intro to differnt oper.pptx
 
Operators
OperatorsOperators
Operators
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 

OPERATORS IN C.pptx

  • 2. WHAT IS OPERATOR? • C support rich set of built-in operators. • We have already used several of them, such as + - * & = < etc. • Operators are used in programs to manipulate data and variables. • An operator is a symbol that perform certain mathematical or logical manipulations. • C operators can be classified into number of categories.
  • 3. TYPES OF OPERATORS • Arithmetic operators • Relational operators • Logical operators • Assigment operators • Increment and decrement operators • Conditional operators • Bitwise operators • Special operators
  • 4. ARITHMETIC OPERATORS • C provides all the basic arithmetic operators. • Arithmetic operators are addition(+),Subtraction(),Multiplication(*),Division(/) and Modulo division(%). • For example : a +b a-b a*b a/b
  • 5. • There are 3 types of arithmetic operator 1.Integer arithmetic(When both operands are single arithmetic expression) ex: 5 + 5 = 10. 2.Real arithmetic(An arithmetic operation involving only real operands ) ex : 6.0/7.0=0.857143 3.Mixed-mode arithmetic(When one of the operands is real and the other is integer) ex: 15/10.0 = 1.5
  • 6. RELATIONAL OPERATORS • Relational operator compares two quantities depending on their relation. • For example : compare the age of two persons,prices of two items and so on. • Relational operator : Greater than(>), Greater than or equal to(>=), Less than(<), Less than or equal to(<=), Equal to(==),Not equal to(!=). Eg: 10 < 20 a ==b
  • 7. LOGICAL OPERATORS • Logical operator which combines two or more relational expressions,is termed as compound logical expression. • C has the following three logical operator. && - Logical AND || - Logical OR ! - Logical NOT For example : if(age>55 && salary<1000)
  • 8. ASSIGNMENT OPERATORS • Assignment operators are used to assign the result of an expression to a variable. = -> Assignment operator Example : a=5; • C has a set of ‘Shorthand’ assignment operator. v op=exp Example : x += 3;
  • 9. INCREMENT AND DECREMENT OPERATORS • The increment operator ++ adds 1 to the operand, while the decrement operator - - subtracts 1 to the operand. ++ - Increment operator -- - Decrement operator • We use the increment and decrement statements in for and while loops. ++m; or m++; --m; or m--;
  • 10. CONDITIONAL OPERATORS • A ternary operator pair “?:” is available in c, the conditional expression of the form exp1 ? exp2 : exp3 • Where exp1,exp2,exp3 are expressions. • exp 1 is evaluated first, if it is true then exp 2 is executed. • If exp 1 is evaluated , it is false then exp3 is executed. a=10; b=15; x=(a>b)?a : b; • It can be achieved using if…else statements.
  • 11. BITWISE OPERATORS • C has a distinction of supporting special operators known as bitwise operator for manipulating of data at bit level. • These operator are used for testing the bits or shifting them right or left. & - bitwise AND | - bitwise OR <<- shift left >>-shift right
  • 12. SPECIAL OPERATORS • C supports some special operators such as comma operator , sizeof operator. • Comma operator : The comma operator used to link the related expression together. For example : for(n=1,m=10,n<=m;n++,m++); • Sizeof operator : Sizeof operator is a compile time operator, it returns the number of bytes the operand occupies. For example : m=sizeof(sum);