SlideShare a Scribd company logo
1 of 19
OPERATORS
REFERENCE BOOK : ANSI C
By
E. BALAGURUSAMY
What is an operator?
An operator is a symbol that tells the
computer to perform certain mathematical or
logical manipulations.
These operators are used in programs to
manipulate data and variables.
They form a part of the mathematical or
logical expressions.
Types of Operators
1. Arithmetic operators +,-,*,/,%
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and decrement operators
6. Conditional operators
7. Bitwise operators
8. Special operators
Expression(Integer, Real, Mixed mode)
It is a sequence of Operands and operators that reduces to
a single value. 89.8+87.7+90 =
30.6 + 56 =86.6 6.2+7+5.4
OPERANDS
Operator
ARITHMETIC OPERATORS:
Arithmetic operators are used to perform numerical
calculations among the values.
OPERATOR MEANING
+ Addition
- Subtraction
* Multiplication
/ Division
Modulus Operator %
-8%-3= -2
8/2= 4
Modulo
Division(Applied only on
Integer values
#include<stdio.h>
void main()
{ int a, b, add, sub, mul, div, rem;
printf("Enter a, b values : ");
scanf("%d%d",&a,&b);
add=a+b; // a=b a=9,b=10 9
sub=a-b 9;
mul=a*b; 0
div=a/b; 0
rem=a%b;
9
// Reading two values
// Addition Operator
// Subtraction Operator
// Multiplication Operator
// Division Operator
// Remainder (Modulo) Operator
printf("Result of addition is=%dn", add); // Result of addition is =9
printf("Result of subtraction=%dn", sub);
printf("Result of multiplication is=%dn", mul);
printf("Result of division is=%dn", div);
printf("Result of remainder=%dn",rem);
}
RELATIONAL OPERATOR:
These are used to compare two quantities and take certain
decision depending on their relation.
If the specified relation is true it returns one. If the
specified relation is false it returns zero.
OPERATOR MEANING
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
== Is equal to
!= Is not equal to
LOGICAL OPERATORS:
These operators are used for testing more than one condition
and making decisions.
'c' has three logical operators they are: AND OR NOT
OPERATOR MEANING
&& Logical AND
|| Logical OR
! Logical NOT
Condition 1 Condition2 Condition1 ||
Condition2
0 0 0
0 1 1
1 1 1
1 0 1
TRUTH TABLE 1 0
0 1
ASSIGNMENT OPERATORS
 These operators are used for assigning the result of an
expression to a variable. Eg. b=a; //b=20,a=10
 C has a set of ‘shorthand’ assignment operator :
variable_name operator=expression;
 a= a*(b+c)
 a*=(b+c)
Eg . a + = 3;
OR
a= a + 3;
SAME
Shorthand Assignment operators
Simple assignment
operator
Shorthand operator
a = a+1 a+=1
a = a-1 a-=1
a = a* (m+n) a*=(m+n)
a = a / (m+n) a/=(m+n)
a = a %b a%=b
INCREMENT & DECREMENT OPERATORS
Two most useful operators which are present in 'c' are
increment and decrement operators. ++ ,--,
The operator ++ adds one to the operand
The operator -- subtracts one from the operand.
Both are unary operators and can be used as pre or post
increment/decrement.
Increment operator increases the value by 1
Preincrement ++a
Postincrement a++
Postdecrement a--
Predecrement -- a
b = a--; a=78
b= 78, a=77
b= --a a=87
b = 86, a=86
INCREMENT & DECREMENT OPERATORS EXAMPLE
#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter the values for a and b :");
scanf("%d %d", &a, &b); //
printf("n The value of c is %d", c=++a);
printf("n The value of c is %d", c=a++);
printf("n The value of c is %d", c=--b);
printf("n The value of c is %d", c=b--);
}
CONDITIONAL OPERATORS/ Ternary
operator
These conditional operator are used to construct conditional
expressions of the form.
Syntax:
exp1?exp2:exp3
a=7,b=9
c= a>b? a : c
are expressions.
Conditional Operators Example
#include<stdio.h>
void main()
{
int a, b,c, x,y;
printf("Enter the values of a and b : ");
scanf("%d %d %d", &a, &b,&c);
x=(a>b)?a:b;
y= (a>b)?(a>c?a:c) : (b>c?b:c);
printf("Biggest Value is :%d",x);
printf("Biggest Value is :%d",y);
}
BITWISE OPERATORS
These operators works on bit level
Applied to Integers only
OPERATOR MEANING
& Bitwise AND
| Bitwise OR
^ Bitwise Exclusive OR
<< Shift Left
>> Shift Right
SPECIAL OPERATORS
'C' supports some special operators such as comma
operator, sizeof operator and pointer operators.
Comma operator: The comma operator is used to combine
related expressions. int I,j,k;
A comma linked list of expressions are
evaluated left to right and the value of right most
expression is the value of combined expression.
Example: expr=(x=11, y=5, x+y);
Special Operators Contd…
Sizeof Operator: sizeof is an operator used to return the
number of bytes the operand occupies.
Syntax: int sum, m;
char c;
sizeof( c) = 1
m=sizeof(sum);
// argument// 2
k=sizeof(2351);

More Related Content

Similar to operators.pptx

C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptxramanathan2006
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdfRichardMathengeSPASP
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 
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.pptxranaashutosh531pvt
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++sunny khan
 
C operators
C operatorsC operators
C operatorsGPERI
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsAmrinder Sidhu
 
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 cSowmya Jyothi
 
Operators in Python
Operators in PythonOperators in Python
Operators in PythonAnusuya123
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 

Similar to operators.pptx (20)

C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdf
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.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
 
Coper in C
Coper in CCoper in C
Coper in C
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
 
C operators
C operatorsC operators
C operators
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
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 Python
Operators in PythonOperators in Python
Operators in Python
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 

operators.pptx

  • 1. OPERATORS REFERENCE BOOK : ANSI C By E. BALAGURUSAMY
  • 2. What is an operator? An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations. These operators are used in programs to manipulate data and variables. They form a part of the mathematical or logical expressions.
  • 3. Types of Operators 1. Arithmetic operators +,-,*,/,% 2. Relational operators 3. Logical operators 4. Assignment operators 5. Increment and decrement operators 6. Conditional operators 7. Bitwise operators 8. Special operators
  • 4. Expression(Integer, Real, Mixed mode) It is a sequence of Operands and operators that reduces to a single value. 89.8+87.7+90 = 30.6 + 56 =86.6 6.2+7+5.4 OPERANDS Operator
  • 5. ARITHMETIC OPERATORS: Arithmetic operators are used to perform numerical calculations among the values. OPERATOR MEANING + Addition - Subtraction * Multiplication / Division Modulus Operator % -8%-3= -2 8/2= 4 Modulo Division(Applied only on Integer values
  • 6. #include<stdio.h> void main() { int a, b, add, sub, mul, div, rem; printf("Enter a, b values : "); scanf("%d%d",&a,&b); add=a+b; // a=b a=9,b=10 9 sub=a-b 9; mul=a*b; 0 div=a/b; 0 rem=a%b; 9 // Reading two values // Addition Operator // Subtraction Operator // Multiplication Operator // Division Operator // Remainder (Modulo) Operator printf("Result of addition is=%dn", add); // Result of addition is =9 printf("Result of subtraction=%dn", sub); printf("Result of multiplication is=%dn", mul); printf("Result of division is=%dn", div); printf("Result of remainder=%dn",rem); }
  • 7. RELATIONAL OPERATOR: These are used to compare two quantities and take certain decision depending on their relation. If the specified relation is true it returns one. If the specified relation is false it returns zero. OPERATOR MEANING < Is less than <= Is less than or equal to > Is greater than >= Is greater than or equal to == Is equal to != Is not equal to
  • 8. LOGICAL OPERATORS: These operators are used for testing more than one condition and making decisions. 'c' has three logical operators they are: AND OR NOT OPERATOR MEANING && Logical AND || Logical OR ! Logical NOT
  • 9. Condition 1 Condition2 Condition1 || Condition2 0 0 0 0 1 1 1 1 1 1 0 1 TRUTH TABLE 1 0 0 1
  • 10. ASSIGNMENT OPERATORS  These operators are used for assigning the result of an expression to a variable. Eg. b=a; //b=20,a=10  C has a set of ‘shorthand’ assignment operator : variable_name operator=expression;  a= a*(b+c)  a*=(b+c) Eg . a + = 3; OR a= a + 3; SAME
  • 11. Shorthand Assignment operators Simple assignment operator Shorthand operator a = a+1 a+=1 a = a-1 a-=1 a = a* (m+n) a*=(m+n) a = a / (m+n) a/=(m+n) a = a %b a%=b
  • 12. INCREMENT & DECREMENT OPERATORS Two most useful operators which are present in 'c' are increment and decrement operators. ++ ,--, The operator ++ adds one to the operand The operator -- subtracts one from the operand. Both are unary operators and can be used as pre or post increment/decrement.
  • 13. Increment operator increases the value by 1 Preincrement ++a Postincrement a++ Postdecrement a-- Predecrement -- a b = a--; a=78 b= 78, a=77 b= --a a=87 b = 86, a=86
  • 14. INCREMENT & DECREMENT OPERATORS EXAMPLE #include<stdio.h> void main() { int a,b,c; printf("Enter the values for a and b :"); scanf("%d %d", &a, &b); // printf("n The value of c is %d", c=++a); printf("n The value of c is %d", c=a++); printf("n The value of c is %d", c=--b); printf("n The value of c is %d", c=b--); }
  • 15. CONDITIONAL OPERATORS/ Ternary operator These conditional operator are used to construct conditional expressions of the form. Syntax: exp1?exp2:exp3 a=7,b=9 c= a>b? a : c are expressions.
  • 16. Conditional Operators Example #include<stdio.h> void main() { int a, b,c, x,y; printf("Enter the values of a and b : "); scanf("%d %d %d", &a, &b,&c); x=(a>b)?a:b; y= (a>b)?(a>c?a:c) : (b>c?b:c); printf("Biggest Value is :%d",x); printf("Biggest Value is :%d",y); }
  • 17. BITWISE OPERATORS These operators works on bit level Applied to Integers only OPERATOR MEANING & Bitwise AND | Bitwise OR ^ Bitwise Exclusive OR << Shift Left >> Shift Right
  • 18. SPECIAL OPERATORS 'C' supports some special operators such as comma operator, sizeof operator and pointer operators. Comma operator: The comma operator is used to combine related expressions. int I,j,k; A comma linked list of expressions are evaluated left to right and the value of right most expression is the value of combined expression. Example: expr=(x=11, y=5, x+y);
  • 19. Special Operators Contd… Sizeof Operator: sizeof is an operator used to return the number of bytes the operand occupies. Syntax: int sum, m; char c; sizeof( c) = 1 m=sizeof(sum); // argument// 2 k=sizeof(2351);