SlideShare a Scribd company logo
1 of 19
OPERATORS
N.V.RAJA SEKHAR REDDY
C Programming Tutorials
www.programming9.com
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.
2 www.programming9.com
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 operators3 www.programming9.com
ARITHMETIC OPERATORS:
 Arithmetic operators are used to perform numerical
calculations among the values.
OPERATOR MEANING
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo Division
4 www.programming9.com
#include<stdio.h>
int main()
{
int a, b, add, sub, mul, div, rem;
printf("Enter a, b values : ");
scanf("%d%d",&a,&b); // Reading two values
add=a+b; // Addition Operator
sub=a-b; // Subtraction Operator
mul=a*b; // Multiplication Operator
div=a/b; // Division Operator
rem=a%b; // Remainder (Modulo) Operator
printf("Result of addition is=%dn", add);
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);
return 0; }
5 www.programming9.com
RELATIONAL OPERATOR:
 Relational Operators 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
6 www.programming9.com
#include<stdio.h>
void main()
{
int a, b;
printf(“Enter values for a and b : ");
scanf("%d %d", &a, &b);
printf("n The < value of a is %d", a<b);
printf("n The <= value of a is %d", a<=b);
printf("n The > value of a is %d", a>b);
printf("n The >= value of a is %d", a>=b);
printf("n The == value of a is %d", a==b);
printf("n The != value of a is %d", a!=b);
}
7 www.programming9.com
Example Program
LOGICAL OPERATORS:
 These operators are used for testing more than one
condition and making decisions.
'c' has three logical operators they are:
OPERATOR MEANING
&& Logical AND
|| Logical OR
! Logical NOT
8 www.programming9.com
Logical Operators Example Program
#include<stdio.h>
void main()
{
int a, b;
printf(“Enter values for a and b : ");
scanf(“%d %d", &a, &b);
printf("n %d",(a<b)&&(a!=b));
printf("n %d",(a<b)||(b<a));
printf("n %d",!(a==b));
}
9 www.programming9.com
ASSIGNMENT OPERATORS
 These operators are used for assigning the result of
an expression to a variable.
 b=a;
OPERATORS:
==, +=, -=, *=, /=, %=,
>>=, <<=, &=, |=, ^=
10 www.programming9.com
Assignment 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 values of= is:%d",c=a+b);
printf("n the values of +=is:%d",c+=b);
printf("n the value of-= is:%d",c-=a);
printf("n the value of *=is:%d",c*=a);
printf("n the value of /=is:%d",c/=b);
printf("n the value of %=is:%d",c%=b);
}
11 www.programming9.com
INCREMENT & DECREMENT
OPERATORS
Two most useful operators which are present in 'c'
are increment and decrement operators.
Operators: ++ and --
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.
12 www.programming9.com
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--);
}
13 www.programming9.com
CONDITIONAL OPERATORS
These conditional operator are used to construct
conditional expressions of the form.
Syntax:
exp1?exp2:exp3.
where exp1,exp2,exp3 are expressions.
Operator: ?: (ternary operator)
14 www.programming9.com
Conditional Operators Example
#include<stdio.h>
void main()
{
int a, b, x;
printf("Enter the values of a add b : ");
scanf("%d %d", &a, &b);
x=(a>b)?a:b;
printf("Biggest Value is :%d",x);
}
15 www.programming9.com
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
16 www.programming9.com
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.
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: value=(x=10, y=5, x+y);
17 www.programming9.com
Special Operators Contd…
Sizeof Operator:
Sizeof is an operator used to return the number
of bytes the operand occupies.
Syntax:
m=sizeof(sum);
k=sizeof(2351);
18 www.programming9.com
www.programming9.com
Like us @
www.facebook.com/programming9
19 www.programming9.com

More Related Content

What's hot (20)

String functions in C
String functions in CString functions in C
String functions in C
 
Strings in C
Strings in CStrings in C
Strings in C
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
C tokens
C tokensC tokens
C tokens
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 

Viewers also liked

Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Shujaat Abbas
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in CPrabhu Govind
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Autonomous RC car using gps
Autonomous RC car using gpsAutonomous RC car using gps
Autonomous RC car using gpsma_np
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVRDaksh Raj Chopra
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR FundamentalsVinit Vyas
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Mahmoud Sadat
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Student
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR MicrocontrollerÖzcan Acar
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICSRobotix 2011
 

Viewers also liked (19)

Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Learn C
Learn CLearn C
Learn C
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Autonomous RC car using gps
Autonomous RC car using gpsAutonomous RC car using gps
Autonomous RC car using gps
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR Fundamentals
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
 
Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR Microcontroller
 
Avr introduction
Avr introductionAvr introduction
Avr introduction
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
AVR programming - BASICS
AVR programming - BASICSAVR programming - BASICS
AVR programming - BASICS
 
Deep C
Deep CDeep C
Deep C
 

Similar to Operators in C Programming

ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsAmrinder Sidhu
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxNithya K
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariTHE NORTHCAP UNIVERSITY
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdfMaryJacob24
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structuresPradipta Mishra
 
OPERATORS.pptx
OPERATORS.pptxOPERATORS.pptx
OPERATORS.pptxPMLAVANYA
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptxramanathan2006
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSivakumar R D .
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 

Similar to Operators in C Programming (20)

ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
 
2. operator
2. operator2. operator
2. operator
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
Theory3
Theory3Theory3
Theory3
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
 
OPERATORS.pptx
OPERATORS.pptxOPERATORS.pptx
OPERATORS.pptx
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Operators in C Programming

  • 1. OPERATORS N.V.RAJA SEKHAR REDDY C Programming Tutorials www.programming9.com
  • 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. 2 www.programming9.com
  • 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 operators3 www.programming9.com
  • 4. ARITHMETIC OPERATORS:  Arithmetic operators are used to perform numerical calculations among the values. OPERATOR MEANING + Addition - Subtraction * Multiplication / Division % Modulo Division 4 www.programming9.com
  • 5. #include<stdio.h> int main() { int a, b, add, sub, mul, div, rem; printf("Enter a, b values : "); scanf("%d%d",&a,&b); // Reading two values add=a+b; // Addition Operator sub=a-b; // Subtraction Operator mul=a*b; // Multiplication Operator div=a/b; // Division Operator rem=a%b; // Remainder (Modulo) Operator printf("Result of addition is=%dn", add); 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); return 0; } 5 www.programming9.com
  • 6. RELATIONAL OPERATOR:  Relational Operators 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 6 www.programming9.com
  • 7. #include<stdio.h> void main() { int a, b; printf(“Enter values for a and b : "); scanf("%d %d", &a, &b); printf("n The < value of a is %d", a<b); printf("n The <= value of a is %d", a<=b); printf("n The > value of a is %d", a>b); printf("n The >= value of a is %d", a>=b); printf("n The == value of a is %d", a==b); printf("n The != value of a is %d", a!=b); } 7 www.programming9.com Example Program
  • 8. LOGICAL OPERATORS:  These operators are used for testing more than one condition and making decisions. 'c' has three logical operators they are: OPERATOR MEANING && Logical AND || Logical OR ! Logical NOT 8 www.programming9.com
  • 9. Logical Operators Example Program #include<stdio.h> void main() { int a, b; printf(“Enter values for a and b : "); scanf(“%d %d", &a, &b); printf("n %d",(a<b)&&(a!=b)); printf("n %d",(a<b)||(b<a)); printf("n %d",!(a==b)); } 9 www.programming9.com
  • 10. ASSIGNMENT OPERATORS  These operators are used for assigning the result of an expression to a variable.  b=a; OPERATORS: ==, +=, -=, *=, /=, %=, >>=, <<=, &=, |=, ^= 10 www.programming9.com
  • 11. Assignment 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 values of= is:%d",c=a+b); printf("n the values of +=is:%d",c+=b); printf("n the value of-= is:%d",c-=a); printf("n the value of *=is:%d",c*=a); printf("n the value of /=is:%d",c/=b); printf("n the value of %=is:%d",c%=b); } 11 www.programming9.com
  • 12. INCREMENT & DECREMENT OPERATORS Two most useful operators which are present in 'c' are increment and decrement operators. Operators: ++ and -- 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. 12 www.programming9.com
  • 13. 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--); } 13 www.programming9.com
  • 14. CONDITIONAL OPERATORS These conditional operator are used to construct conditional expressions of the form. Syntax: exp1?exp2:exp3. where exp1,exp2,exp3 are expressions. Operator: ?: (ternary operator) 14 www.programming9.com
  • 15. Conditional Operators Example #include<stdio.h> void main() { int a, b, x; printf("Enter the values of a add b : "); scanf("%d %d", &a, &b); x=(a>b)?a:b; printf("Biggest Value is :%d",x); } 15 www.programming9.com
  • 16. 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 16 www.programming9.com
  • 17. 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. 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: value=(x=10, y=5, x+y); 17 www.programming9.com
  • 18. Special Operators Contd… Sizeof Operator: Sizeof is an operator used to return the number of bytes the operand occupies. Syntax: m=sizeof(sum); k=sizeof(2351); 18 www.programming9.com