SlideShare a Scribd company logo
1 of 20
Operators in c programming
Name : Krishna kumar Pankaj
Roll No : 13/IT/22
What is Operators ?
 An operator is a symbol that is used to perform certain mathematical or
logical operations.
 Operator is used to manipulate data and variables.
Types of operators
 In C programming Operators classified in to various categories
 1. Arithmetic operators
 2. Relational operators
 3. Logical operators
 4. Assignment operators
 5. Increment & Decrement operators
 6. Conditional operators
 7. Bitwise operators
 8. Special operators
Arithmetic operators
 Arithmetic operators used to perform Arithmetic operations.
 There are following Arithmetic operators in c language
Example :
 #include<stdio.h>
#include<conio.h>
int main()
{
int x=25;
int y=5;
printf("%d+%d=%dn",x,y,x+y);
printf("%d-%d=%dn",x,y,x-y);
printf("%d*%d=%dn",x,y,x*y);
printf("%d/%d=%dn",x,y,x/y);
getch();
}
 Output :
25+5=30
25-5=20
25*5=125
25/5=5
Relational operators
 Relational operators compare between two operands and return in terms of
true or false
 There are following Relational operators.
Example :
#include<conio.h>
#include<stdio.h>
int 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);
getch();
 }
Logical operator
 A Logical operator is used to compare or evaluate logical or relational
operations.
 There are following logical operators
Example :
#include<stdio.h>
#include<conio.h>
int 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));
getch();
}
Assignment operator
 An Assignment operator is used to assign a constant or a value of one
variable to another.
 = is an Assignment operator.
 you can use the assignment for multiple assignment as follows:
 x=y=z=20;
Increment Operator(++)
 Increment operator are increase the value of subsequent
 Increment operator are two types as follows:
• post Increment
• Ex : x=5;x++;x=5
• pre Increment
• x=5;++x;x=6
Decrement operator(--)
 Decrement operator Decrease the value to one ,two and so on.
 Decrement operator are also two type as
• Post Decrement
• x=5;x--;x=5
• pre decrement
• x=5;--x;x=4
Example of Increment & Decrement
operator
#include<stdio.h>
#include<conio.h>
int 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--);
}
 Output
Enter the value of a and b : 3 ,7
The value of c is 4
The value of c is 4
The value of c is 6
The value of c is 6
Conditional operator
 They are also called as ternary operator.
 They are also called as ?: operator.
 Ternary operator Takes on 3 Argument
Where
1) Expression 1 is condition
2) Expression2 is Statement Followed if Condition is True
3) Expression2 is Statement Followed if Condition is False
True
Condition ? Block 1 : Block 2
False
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);
}
Bitwise Operator
 One of the C powerful Features is a set of bit manipulation operators
 There are various Bitwise Operators in C as following Table.
1. & (bitwise AND) Takes two numbers as operand and does AND on every bit of
two numbers. The result of AND is 1 only if both bits are 1.
2. | (bitwise OR) Takes two numbers as operand and does OR on every bit of two
numbers. The result of OR is 1 any of the two bits is 1.
3. ^ (bitwise XOR) Takes two numbers as operand and does XOR on every bit of
two numbers. The result of XOR is 1 if the two bits are different.
4. << (left shift) Takes two numbers, left shifts the bits of first operand, the
second operand decides the number of places to shift.
5. >> (right shift) Takes two numbers, right shifts the bits of first operand, the
second operand decides the number of places to shift.
6. ~ (bitwise NOT) Takes one number and inverts all bits of it
Special Operator
 There are many special operators use in c programming.
 Comma operator
 Sizeof Operator
Comma Operator
 Evaluate of comma operator – Left to Right
 Uses of comma operator as following :
 Multiples Declaration
 Multiples Initialization
 Multiples Variation
 Multiples Statement
 Example of comma operator
 X=12,y=10,z=18
 For( i=0,j=0;i<5,j<5;i++,j++ )
Sizeof operator
 Sizeof operator calculate the size of data
 i.e: How many bit a specific data having.
 Syntax of sizeof operator:
 Sizeof(variable);
Example :
sizeof(a), where a is interger, will return 4
Thank you
Any Queries ???
Go to Google Or
Email me at “Krishna.pankaj@hotmail.com”

More Related Content

What's hot

Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
vishaljot_kaur
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
bajiajugal
 

What's hot (20)

Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Structure in C
Structure in CStructure in C
Structure in C
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Functions in C
Functions in CFunctions in C
Functions in C
 
C functions
C functionsC functions
C functions
 

Similar to Operators

data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 

Similar to Operators (20)

Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
 
B.sc CSIT 2nd semester C++ Unit2
B.sc CSIT  2nd semester C++ Unit2B.sc CSIT  2nd semester C++ Unit2
B.sc CSIT 2nd semester C++ Unit2
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
introduction to c programming and C History.pptx
introduction to c programming and C History.pptxintroduction to c programming and C History.pptx
introduction to c programming and C History.pptx
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
additional.pptx
additional.pptxadditional.pptx
additional.pptx
 
Theory3
Theory3Theory3
Theory3
 
Interesting facts on c
Interesting facts on cInteresting facts on c
Interesting facts on c
 
C program
C programC program
C program
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
C++
C++C++
C++
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
C-PPT.pdf
C-PPT.pdfC-PPT.pdf
C-PPT.pdf
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 

Recently uploaded

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 

Recently uploaded (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 

Operators

  • 1. Operators in c programming Name : Krishna kumar Pankaj Roll No : 13/IT/22
  • 2. What is Operators ?  An operator is a symbol that is used to perform certain mathematical or logical operations.  Operator is used to manipulate data and variables.
  • 3. Types of operators  In C programming Operators classified in to various categories  1. Arithmetic operators  2. Relational operators  3. Logical operators  4. Assignment operators  5. Increment & Decrement operators  6. Conditional operators  7. Bitwise operators  8. Special operators
  • 4. Arithmetic operators  Arithmetic operators used to perform Arithmetic operations.  There are following Arithmetic operators in c language
  • 5. Example :  #include<stdio.h> #include<conio.h> int main() { int x=25; int y=5; printf("%d+%d=%dn",x,y,x+y); printf("%d-%d=%dn",x,y,x-y); printf("%d*%d=%dn",x,y,x*y); printf("%d/%d=%dn",x,y,x/y); getch(); }  Output : 25+5=30 25-5=20 25*5=125 25/5=5
  • 6. Relational operators  Relational operators compare between two operands and return in terms of true or false  There are following Relational operators.
  • 7. Example : #include<conio.h> #include<stdio.h> int 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); getch();  }
  • 8. Logical operator  A Logical operator is used to compare or evaluate logical or relational operations.  There are following logical operators
  • 9. Example : #include<stdio.h> #include<conio.h> int 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)); getch(); }
  • 10. Assignment operator  An Assignment operator is used to assign a constant or a value of one variable to another.  = is an Assignment operator.  you can use the assignment for multiple assignment as follows:  x=y=z=20;
  • 11. Increment Operator(++)  Increment operator are increase the value of subsequent  Increment operator are two types as follows: • post Increment • Ex : x=5;x++;x=5 • pre Increment • x=5;++x;x=6
  • 12. Decrement operator(--)  Decrement operator Decrease the value to one ,two and so on.  Decrement operator are also two type as • Post Decrement • x=5;x--;x=5 • pre decrement • x=5;--x;x=4
  • 13. Example of Increment & Decrement operator #include<stdio.h> #include<conio.h> int 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--); }  Output Enter the value of a and b : 3 ,7 The value of c is 4 The value of c is 4 The value of c is 6 The value of c is 6
  • 14. Conditional operator  They are also called as ternary operator.  They are also called as ?: operator.  Ternary operator Takes on 3 Argument Where 1) Expression 1 is condition 2) Expression2 is Statement Followed if Condition is True 3) Expression2 is Statement Followed if Condition is False True Condition ? Block 1 : Block 2 False
  • 15. 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); }
  • 16. Bitwise Operator  One of the C powerful Features is a set of bit manipulation operators  There are various Bitwise Operators in C as following Table. 1. & (bitwise AND) Takes two numbers as operand and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1. 2. | (bitwise OR) Takes two numbers as operand and does OR on every bit of two numbers. The result of OR is 1 any of the two bits is 1. 3. ^ (bitwise XOR) Takes two numbers as operand and does XOR on every bit of two numbers. The result of XOR is 1 if the two bits are different. 4. << (left shift) Takes two numbers, left shifts the bits of first operand, the second operand decides the number of places to shift. 5. >> (right shift) Takes two numbers, right shifts the bits of first operand, the second operand decides the number of places to shift. 6. ~ (bitwise NOT) Takes one number and inverts all bits of it
  • 17. Special Operator  There are many special operators use in c programming.  Comma operator  Sizeof Operator
  • 18. Comma Operator  Evaluate of comma operator – Left to Right  Uses of comma operator as following :  Multiples Declaration  Multiples Initialization  Multiples Variation  Multiples Statement  Example of comma operator  X=12,y=10,z=18  For( i=0,j=0;i<5,j<5;i++,j++ )
  • 19. Sizeof operator  Sizeof operator calculate the size of data  i.e: How many bit a specific data having.  Syntax of sizeof operator:  Sizeof(variable); Example : sizeof(a), where a is interger, will return 4
  • 20. Thank you Any Queries ??? Go to Google Or Email me at “Krishna.pankaj@hotmail.com”