SlideShare a Scribd company logo
12
Most read
15
Most read
C Operators
1. Arithmetic operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increments and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
Arithmetic operators
Operator Meaning
+ Addition or Unary Plus
– Subtraction or Unary Minus
* Multiplication
/ Division
% Modulus Operator
Integer Arithmetic
Let x = 27 and y = 5
z = x + y  32
z = x – y  22
z = x * y  115
z = x % y  2
z = x / y  5
Floating point arithmetic
Let x = 14.0 and y = 4.0 then
z = x + y  18.0
z = x – y  10.0
z = x * y  56.0
z = x / y  3.50
Mixed mode arithmetic
15/10.0 = 1.5
Relational Operators
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
Relational Expressions
6.5 <= 25 TRUE
-65 > 0 FALSE
10 < 7 + 5 TRUE
Logical Operators
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
Find out the answer
a > b && x = = 10
a < m || a < n
! (x >= y)
a = 5
b = 4
x=10, y = 9
m=6
n = 3
Assignment Operators
Statement with simple
assignment operator
Statement with
shorthand operator
a = a + 1 a += 1
a = a – 1 a -= 1
a = a * (n+1) a *= (n+1)
a = a / (n+1) a /= (n+1)
a = a % b a %= b
What is the output?
#define N 100 //creates a variable N with constant value 100
#define A 2 //creates a variable A with constant value 2
main() //start of the program
{
int a; //variable a declaration
a = A; //assigns value 2 to a
while (a < N) //while value of a is less than N
{ //evaluate or do the following
printf(“%d n”,a); //print the current value of a
a *= a; //shorthand form of a = a * a
} //end of the loop
} //end of the program
Output
2
4
16
Increment and Decrement
Operators
1. ++ v
2. v++
3. – –v
4. V--
m = 5;
y = ++m; (prefix)
After Execution:
y=6, m=6
m = 5;
y = m++; (post
fix)
After Execution:
y=5, m=6
Conditional or Ternary
Operator
a = 10;
b = 15;
x = (a > b) ? a : b
Bitwise Operators
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise Exclusive
<< Shift left
>> Shift right
Special Operators
comma operator
size of operator
pointer operators (& and *)
member selection operators (. and ->).
The Comma Operator
value = (x = 10, y = 5, x + y);
In for loops:
for (n=1, m=10, n <=m; n++,m++)
In while loops
While (c=getchar(), c != ‘1’)
Exchanging values
t = x, x = y, y = t;
The size of Operator
m = sizeof (sum);
n = sizeof (long int);
k = sizeof (235L);
What is the output?
main() //start of program
{
int a, b, c, d; //declaration of variables
a = 15; b = 10; c = ++a-b; //assign values to variables
printf (“a = %d, b = %d, c = %dn”, a,b,c); //print the values
d=b++ + a;
printf (“a = %d, b = %d, d = %dn, a,b,d);
printf (“a / b = %dn, a / b);
printf (“a %% b = %dn, a % b);
printf (“a *= b = %dn, a *= b);
printf (“%dn, (c > d) ? 1 : 0 );
printf (“%dn, (c < d) ? 1 : 0 );
}

More Related Content

What's hot (20)

PPT
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
PPTX
Control statements in c
Sathish Narayanan
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
Strings in C language
P M Patil
 
PPTX
Functions in c
sunila tharagaturi
 
PDF
Operators in c programming
savitamhaske
 
PPTX
Operators
Krishna Kumar Pankaj
 
PPTX
C Programming: Control Structure
Sokngim Sa
 
PPTX
Operators in java
Then Murugeshwari
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPTX
Managing input and output operation in c
yazad dumasia
 
PPTX
Operator.ppt
Darshan Patel
 
PPTX
Operators and expressions in C++
Neeru Mittal
 
PPTX
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
PDF
Character Array and String
Tasnima Hamid
 
PDF
Generic Programming
Muhammad Alhalaby
 
PPTX
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
PPT
Operators in C Programming
programming9
 
PPTX
Functions in C
Kamal Acharya
 
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Control statements in c
Sathish Narayanan
 
Pure virtual function and abstract class
Amit Trivedi
 
Strings in C language
P M Patil
 
Functions in c
sunila tharagaturi
 
Operators in c programming
savitamhaske
 
C Programming: Control Structure
Sokngim Sa
 
Operators in java
Then Murugeshwari
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Oop c++class(final).ppt
Alok Kumar
 
Managing input and output operation in c
yazad dumasia
 
Operator.ppt
Darshan Patel
 
Operators and expressions in C++
Neeru Mittal
 
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Character Array and String
Tasnima Hamid
 
Generic Programming
Muhammad Alhalaby
 
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Operators in C Programming
programming9
 
Functions in C
Kamal Acharya
 

Similar to Types of operators in C (20)

PPTX
Operators in C programming language.pptx
b221382
 
PDF
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
PPTX
Operators-computer programming and utilzation
Kaushal Patel
 
PPTX
PROGRAMMING IN C - Operators.pptx
Nithya K
 
PPTX
Operators inc c language
Tanmay Modi
 
PDF
ICP - Lecture 5
Hassaan Rahman
 
PPTX
C Operators and Control Structures.pptx
ramanathan2006
 
PPTX
operators.pptx
ruchisuru20001
 
PDF
C Operators and Control Structures.pdf
MaryJacob24
 
PPT
Operators in c language
Amit Singh
 
PPTX
operators_group_2[1].pptx PLEASE DOWNLOAD
aluffssdd804
 
PPTX
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
LeahRachael
 
PDF
Types of Operators in C
Thesis Scientist Private Limited
 
PPTX
3. C_OperatorsExpressions on c languyage.pptx
iramulittihad
 
PDF
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
PDF
introduction to c programming - Topic 3.pdf
rajd20284
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PPTX
C operators
Rupanshi rawat
 
PPTX
introduction to c programming and C History.pptx
ManojKhadilkar1
 
Operators in C programming language.pptx
b221382
 
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
Operators-computer programming and utilzation
Kaushal Patel
 
PROGRAMMING IN C - Operators.pptx
Nithya K
 
Operators inc c language
Tanmay Modi
 
ICP - Lecture 5
Hassaan Rahman
 
C Operators and Control Structures.pptx
ramanathan2006
 
operators.pptx
ruchisuru20001
 
C Operators and Control Structures.pdf
MaryJacob24
 
Operators in c language
Amit Singh
 
operators_group_2[1].pptx PLEASE DOWNLOAD
aluffssdd804
 
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
LeahRachael
 
Types of Operators in C
Thesis Scientist Private Limited
 
3. C_OperatorsExpressions on c languyage.pptx
iramulittihad
 
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
introduction to c programming - Topic 3.pdf
rajd20284
 
6 operators-in-c
Rohit Shrivastava
 
6 operators-in-c
Rohit Shrivastava
 
C operators
Rupanshi rawat
 
introduction to c programming and C History.pptx
ManojKhadilkar1
 
Ad

More from Prabhu Govind (20)

PPT
Preprocessor in C
Prabhu Govind
 
PPT
Memory allocation in c
Prabhu Govind
 
PPT
File in c
Prabhu Govind
 
PPT
Pointers in C
Prabhu Govind
 
PPT
Unions in c
Prabhu Govind
 
PPT
Structure in c
Prabhu Govind
 
PPT
Array & string
Prabhu Govind
 
PPT
Recursive For S-Teacher
Prabhu Govind
 
PPT
User defined Functions in C
Prabhu Govind
 
PPT
Pre defined Functions in C
Prabhu Govind
 
PPT
Looping in C
Prabhu Govind
 
PPT
Branching in C
Prabhu Govind
 
PPT
Operators in C
Prabhu Govind
 
PPT
Statements in C
Prabhu Govind
 
PPT
Data types in C
Prabhu Govind
 
PPT
Constants in C
Prabhu Govind
 
PPT
Variables_c
Prabhu Govind
 
PPT
Tokens_C
Prabhu Govind
 
PDF
Computer basics
Prabhu Govind
 
PDF
Computer fundamentals
Prabhu Govind
 
Preprocessor in C
Prabhu Govind
 
Memory allocation in c
Prabhu Govind
 
File in c
Prabhu Govind
 
Pointers in C
Prabhu Govind
 
Unions in c
Prabhu Govind
 
Structure in c
Prabhu Govind
 
Array & string
Prabhu Govind
 
Recursive For S-Teacher
Prabhu Govind
 
User defined Functions in C
Prabhu Govind
 
Pre defined Functions in C
Prabhu Govind
 
Looping in C
Prabhu Govind
 
Branching in C
Prabhu Govind
 
Operators in C
Prabhu Govind
 
Statements in C
Prabhu Govind
 
Data types in C
Prabhu Govind
 
Constants in C
Prabhu Govind
 
Variables_c
Prabhu Govind
 
Tokens_C
Prabhu Govind
 
Computer basics
Prabhu Govind
 
Computer fundamentals
Prabhu Govind
 
Ad

Recently uploaded (20)

PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 

Types of operators in C

  • 1. C Operators 1. Arithmetic operators 2. Relational Operators 3. Logical Operators 4. Assignment Operators 5. Increments and Decrement Operators 6. Conditional Operators 7. Bitwise Operators 8. Special Operators
  • 2. Arithmetic operators Operator Meaning + Addition or Unary Plus – Subtraction or Unary Minus * Multiplication / Division % Modulus Operator
  • 3. Integer Arithmetic Let x = 27 and y = 5 z = x + y  32 z = x – y  22 z = x * y  115 z = x % y  2 z = x / y  5
  • 4. Floating point arithmetic Let x = 14.0 and y = 4.0 then z = x + y  18.0 z = x – y  10.0 z = x * y  56.0 z = x / y  3.50
  • 6. Relational Operators 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
  • 7. Relational Expressions 6.5 <= 25 TRUE -65 > 0 FALSE 10 < 7 + 5 TRUE
  • 8. Logical Operators Operator Meaning && Logical AND || Logical OR ! Logical NOT
  • 9. Find out the answer a > b && x = = 10 a < m || a < n ! (x >= y) a = 5 b = 4 x=10, y = 9 m=6 n = 3
  • 10. Assignment Operators Statement with simple assignment operator Statement with shorthand operator a = a + 1 a += 1 a = a – 1 a -= 1 a = a * (n+1) a *= (n+1) a = a / (n+1) a /= (n+1) a = a % b a %= b
  • 11. What is the output? #define N 100 //creates a variable N with constant value 100 #define A 2 //creates a variable A with constant value 2 main() //start of the program { int a; //variable a declaration a = A; //assigns value 2 to a while (a < N) //while value of a is less than N { //evaluate or do the following printf(“%d n”,a); //print the current value of a a *= a; //shorthand form of a = a * a } //end of the loop } //end of the program Output 2 4 16
  • 12. Increment and Decrement Operators 1. ++ v 2. v++ 3. – –v 4. V-- m = 5; y = ++m; (prefix) After Execution: y=6, m=6 m = 5; y = m++; (post fix) After Execution: y=5, m=6
  • 13. Conditional or Ternary Operator a = 10; b = 15; x = (a > b) ? a : b
  • 14. Bitwise Operators Operator Meaning & Bitwise AND | Bitwise OR ^ Bitwise Exclusive << Shift left >> Shift right
  • 15. Special Operators comma operator size of operator pointer operators (& and *) member selection operators (. and ->).
  • 16. The Comma Operator value = (x = 10, y = 5, x + y); In for loops: for (n=1, m=10, n <=m; n++,m++) In while loops While (c=getchar(), c != ‘1’) Exchanging values t = x, x = y, y = t;
  • 17. The size of Operator m = sizeof (sum); n = sizeof (long int); k = sizeof (235L);
  • 18. What is the output? main() //start of program { int a, b, c, d; //declaration of variables a = 15; b = 10; c = ++a-b; //assign values to variables printf (“a = %d, b = %d, c = %dn”, a,b,c); //print the values d=b++ + a; printf (“a = %d, b = %d, d = %dn, a,b,d); printf (“a / b = %dn, a / b); printf (“a %% b = %dn, a % b); printf (“a *= b = %dn, a *= b); printf (“%dn, (c > d) ? 1 : 0 ); printf (“%dn, (c < d) ? 1 : 0 ); }