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

PDF
Unit ii chapter 1 operator and expressions in c
PDF
introduction to c programming - Topic 3.pdf
PPTX
Operators and Expressions
PPT
Operators and Expressions in C++
PPTX
OPERATORS IN C.pptx
PPTX
OPERATORS IN C.pptx
PPTX
3. C_OperatorsExpressions on c languyage.pptx
PPTX
Chapter 3 dti2143
Unit ii chapter 1 operator and expressions in c
introduction to c programming - Topic 3.pdf
Operators and Expressions
Operators and Expressions in C++
OPERATORS IN C.pptx
OPERATORS IN C.pptx
3. C_OperatorsExpressions on c languyage.pptx
Chapter 3 dti2143

Similar to OPERATORS IN C.pptx (20)

PDF
Coper in C
PPTX
Unit-2_chap-4.pptx you from the heart of the
PPTX
operators.pptx
PDF
Module2.1_Programming_Branching_and_looping.pdf
PPTX
Operators in c-1.pptxOperators in c-1.pptx
PPTX
This slide contains information about Operators in C.pptx
PPTX
OPERATORS OF C++
PPTX
Operators-computer programming and utilzation
PPTX
IOS Swift Language 3rd tutorial
PPTX
Csc240 -lecture_5
PPTX
C language operators
PPTX
Operator in C language
PPTX
Cse lecture-4.1-c operators and expression
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
PPT
operators and expressions in c++
PPTX
Operators and expressions in C++
PPTX
Operator in programming in C engineering
PPTX
Simran Roy Operator in Programming in C Language
PPT
Operation and expression in c++
PDF
Types of Operators in C
Coper in C
Unit-2_chap-4.pptx you from the heart of the
operators.pptx
Module2.1_Programming_Branching_and_looping.pdf
Operators in c-1.pptxOperators in c-1.pptx
This slide contains information about Operators in C.pptx
OPERATORS OF C++
Operators-computer programming and utilzation
IOS Swift Language 3rd tutorial
Csc240 -lecture_5
C language operators
Operator in C language
Cse lecture-4.1-c operators and expression
Python Programming | JNTUK | UNIT 1 | Lecture 5
operators and expressions in c++
Operators and expressions in C++
Operator in programming in C engineering
Simran Roy Operator in Programming in C Language
Operation and expression in c++
Types of Operators in C
Ad

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Machine learning based COVID-19 study performance prediction
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
A comparative analysis of optical character recognition models for extracting...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A Presentation on Artificial Intelligence
Machine learning based COVID-19 study performance prediction
MIND Revenue Release Quarter 2 2025 Press Release
A comparative analysis of optical character recognition models for extracting...
“AI and Expert System Decision Support & Business Intelligence Systems”
Ad

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