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
OperatorsOperators
Operators
jayesh30sikchi
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
Sachin Sharma
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
vishaljot_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

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
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
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
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
 
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
 
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
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 

Recently uploaded (20)

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
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
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
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...
 
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
 
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
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 

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);