際際滷

際際滷Share a Scribd company logo
VAIBHAV JAIN ,PRATYAKSH
,HIMANSHI ,SAMIPTA , SHIVAM.
Arithmetic operators
Assignment operators
Relational operators
Logical operators
Bit wise operators
Conditional operators (ternary operators)
Increment/decrement operators
Special operators.
To study.
 The symbols which are used to perform logical and
mathematical operations in a C program are called C
operators.
 These C operators join individual constants and
variables to form expressions.
 Operators, functions, constants and variables are
combined together to form expressions.
Introduction

Types of Operators Description
Arithmetic Operators
Perform mathematical calculations like addition,
subtraction, multiplication, division and modulus
Assignment
Operators
Assign the values for the variables in C programs.
Relational operators Compare the value of two variables.
Logical operators Perform logical operations on the given two variables.
Bit wise operators Perform bit operations on given two variables.
Conditional (ternary)
operators
Conditional operators return one value if condition is
true and returns another value is condition is false.
Increment/decrement
operators
Either increase or decrease the value of the variable by
one.
Special operators &, *, sizeof( ) and ternary operators.
Types of C Operators
Arithmetic
Operators/Operatio
n
Example
+ (Addition) A+B
 (Subtraction) A-B
* (multiplication) A*B
/ (Division) A/B
% (Modulus) A%B
ARITHMETIC OPERATORS IN C
#include <stdio.h>
int main()
{
int a=40,b=20, add,sub,mul,div,mod;
add = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("Addition of a, b is : %dn", add);
printf("Subtraction of a, b is : %dn", sub);
printf("Multiplication of a, b is : %dn", mul);
printf("Division of a, b is : %dn", div);
printf("Modulus of a, b is : %dn", mod);
return 0;
}
Example showing use of Arithmetic
Operator

Operators Example/Description
=
test = 10;
10 is assigned to variable test
+=
test += 10;
This is same as test = test + 10
-=
test -= 10;
This is same as test = test  10
*=
test *= 10;
This is same as test = test * 10
/=
test /= 10;
This is same as test = test / 10
%=
test %= 10;
This is same as test = test % 10
&=
test&=10;
This is same as test = test & 10
^=
test ^= 10;
This is same as test = test ^ 10
ASSIGNMENT OPERATORS IN C
# include <stdio.h>
int main()
{
int Total=0,i;
for(i=0;i<10;i++)
{
Total+=i; // This is same as Total = Toatal+i
}
printf("Total = %d", Total);
return 0;
}
Example showing use of Assignment
Operator

Operators Example/Description
> x > y (x is greater than y)
< x < y (x is less than y)
>= x >= y (x is greater than or equal to y)
<= x <= y (x is less than or equal to y)
== x == y (x is equal to y)
!= x != y (x is not equal to y)
RELATIONAL OPERATORS IN C
Relational operators are used to find the relation between two
variables. i.e. to compare the values of two variables in a C program.
#include <stdio.h>
int main()
{
int m=40,n=20;
if (m == n)
{
printf("m and n are equal");
}
else
{
printf("m and n are not equal");
}
return 0;
}
Example showing use of Relational
Operator
Operators Example/Description
&&
(logical AND)
(a>5)&&(b<5)
It returns true when both conditions are true
| |
(logical OR)
(a>=10)||(b>=10)
It returns true when at-least one of the condition is
true
!
(logical NOT)
!((a>5)&&(b<5))
It reverses the state of the operand ((a>5) &&
(b<5))
If ((a>5) && (b<5)) is true, logical NOT operator
makes it false
LOGICAL OPERATORS IN C

#include <stdio.h>
int main()
{
int m=40,n=20;
int a=20,p=30;
if (m>n && m !=0)
{ printf("&& Operator : Both conditions are truen"); }
if (a>p | | p!=20)
{ printf("| | Operator : Only one condition is truen"); }
if (!(m>n && m !=0))
{ printf("! Operator : Both conditions are truen"); }
else
{ printf("! Operator : Both conditions are true. " 
"But, status is inverted as falsen");
}
return 0;
}
Example showing use of Logical
Operator
 These operators are used to perform bit operations.
Decimal values are converted into binary values
which are the sequence of bits and bit wise operators
work on these bits. Following are bitwise operator
1) & Bitwise AND
2 ) | Bitwise OR
3) ~ Bitwise NOT
4) ^ XOR
5) << Left Shift
6) >> Right Shift
BIT WISE OPERATORS IN C

#include <stdio.h>
int main()
{
int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ;
AND_opr = (m&n);
OR_opr = (m|n);
NOT_opr = (~m);
XOR_opr = (m^n);
printf("AND_opr value = %dn",AND_opr );
printf("OR_opr value = %dn",OR_opr );
printf("NOT_opr value = %dn",NOT_opr );
printf("XOR_opr value = %dn",XOR_opr );
printf("left_shift value = %dn", m << 1);
printf("right_shift value = %dn", m >> 1);
}
Program showing Bitwise Operator in C
 Conditional operators return one value if condition
is true and returns another value is condition is false.
 This operator is also called as ternary operator.
Syntax :
Example :
(Condition? true_value: false_value);
(A > 100 ? 0 : 1);
CONDITIONAL OR TERNARY
OPERATORS IN C
#include <stdio.h>
int main()
{
int x=1, y ;
y = ( x ==1 ? 2 : 0 ) ;
printf("x value is %dn", x);
printf("y value is %d", y);
return 0;
}
Program for use of Ternary Operator

 Increment operators are used to increase the value of
the variable by one and decrement operators are
used to decrease the value of the variable by one in C
programs.
Increment operator
++var_name; (or) var_name++;
Decrement operator
- -var_name; (or) var_name  -;
Increment /Decrement
Operators
#include <stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i);
i++;
}
return 0;
}
Example for increment operators
#include <stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i);
i--;
}
return 0;
}
Example for Decrement operators

More Related Content

Similar to C PRESENTATION.pptx (20)

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
RichardMathengeSPASP
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Kathirvel Ayyaswamy
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
HARSHSHARMA840
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
MaryJacob24
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
ranaashutosh531pvt
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
teach4uin
C operator and expression
C operator and expressionC operator and expression
C operator and expression
LavanyaManokaran
cprogrammingoperator.ppt
cprogrammingoperator.pptcprogrammingoperator.ppt
cprogrammingoperator.ppt
georgejustymirobi1
Project in TLE
Project in TLEProject in TLE
Project in TLE
PGT_13
power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"
sj9399037128
Report Group 4 Constants and Variables
Report Group 4 Constants and VariablesReport Group 4 Constants and Variables
Report Group 4 Constants and Variables
Genard Briane Ancero
Report Group 4 Constants and Variables(TLE)
Report Group 4 Constants and Variables(TLE)Report Group 4 Constants and Variables(TLE)
Report Group 4 Constants and Variables(TLE)
Genard Briane Ancero
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
Simplilearn
Operators
OperatorsOperators
Operators
VijayaLakshmi506
Module 2_PPT_P1 POP Notes module 2 fdfd.pdf
Module 2_PPT_P1 POP Notes module 2 fdfd.pdfModule 2_PPT_P1 POP Notes module 2 fdfd.pdf
Module 2_PPT_P1 POP Notes module 2 fdfd.pdf
anilcsbs
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
REHAN IJAZ
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
Mohd Harris Ahmad Jaal
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
ANANT VYAS
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
RichardMathengeSPASP
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Kathirvel Ayyaswamy
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
MaryJacob24
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
ranaashutosh531pvt
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
teach4uin
C operator and expression
C operator and expressionC operator and expression
C operator and expression
LavanyaManokaran
Project in TLE
Project in TLEProject in TLE
Project in TLE
PGT_13
power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"
sj9399037128
Report Group 4 Constants and Variables
Report Group 4 Constants and VariablesReport Group 4 Constants and Variables
Report Group 4 Constants and Variables
Genard Briane Ancero
Report Group 4 Constants and Variables(TLE)
Report Group 4 Constants and Variables(TLE)Report Group 4 Constants and Variables(TLE)
Report Group 4 Constants and Variables(TLE)
Genard Briane Ancero
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
Simplilearn
Module 2_PPT_P1 POP Notes module 2 fdfd.pdf
Module 2_PPT_P1 POP Notes module 2 fdfd.pdfModule 2_PPT_P1 POP Notes module 2 fdfd.pdf
Module 2_PPT_P1 POP Notes module 2 fdfd.pdf
anilcsbs
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
REHAN IJAZ
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
Mohd Harris Ahmad Jaal
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
ANANT VYAS

Recently uploaded (20)

Frankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkundeFrankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkunde
Lisa Emerson
only history of java.pptx real bihind the name java
only history of java.pptx real bihind the name javaonly history of java.pptx real bihind the name java
only history of java.pptx real bihind the name java
mushtaqsaliq9
autonomous vehicle project for engineering.pdf
autonomous vehicle project for engineering.pdfautonomous vehicle project for engineering.pdf
autonomous vehicle project for engineering.pdf
JyotiLohar6
Unit II: Design of Static Equipment Foundations
Unit II: Design of Static Equipment FoundationsUnit II: Design of Static Equipment Foundations
Unit II: Design of Static Equipment Foundations
Sanjivani College of Engineering, Kopargaon
Industrial Construction shed PEB MFG.pdf
Industrial Construction shed PEB MFG.pdfIndustrial Construction shed PEB MFG.pdf
Industrial Construction shed PEB MFG.pdf
PLINTH & ROOFS
How to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using ArduinoHow to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using Arduino
CircuitDigest
How Engineering Model Making Brings Designs to Life.pdf
How Engineering Model Making Brings Designs to Life.pdfHow Engineering Model Making Brings Designs to Life.pdf
How Engineering Model Making Brings Designs to Life.pdf
Maadhu Creatives-Model Making Company
Sachpazis: Foundation Analysis and Design: Single Piles
Sachpazis: Foundation Analysis and Design: Single PilesSachpazis: Foundation Analysis and Design: Single Piles
Sachpazis: Foundation Analysis and Design: Single Piles
Dr.Costas Sachpazis
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Brian Gongol
Lectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).pptLectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).ppt
SherifElGohary7
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
slayshadow705
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
Syntax Directed Definitions  Synthesized Attributes  and  Inherited AttributesSyntax Directed Definitions  Synthesized Attributes  and  Inherited Attributes
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
GM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptxGM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptx
crdslalcomumbai
Industrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products ProfileIndustrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products Profile
zebcoeng
Mathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptxMathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptx
ppkmurthy2006
CS3451 INTRODUCTIONN TO OS unit ONE .pdf
CS3451 INTRODUCTIONN TO OS unit ONE .pdfCS3451 INTRODUCTIONN TO OS unit ONE .pdf
CS3451 INTRODUCTIONN TO OS unit ONE .pdf
PonniS7
TM-ASP-101-RF_Air Press manual crimping machine.pdf
TM-ASP-101-RF_Air Press manual crimping machine.pdfTM-ASP-101-RF_Air Press manual crimping machine.pdf
TM-ASP-101-RF_Air Press manual crimping machine.pdf
ChungLe60
Water Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control Monthly - March 2025.pdfWater Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control Monthly - March 2025.pdf
Water Industry Process Automation & Control
Engineering at Lovely Professional University (LPU).pdf
Engineering at Lovely Professional University (LPU).pdfEngineering at Lovely Professional University (LPU).pdf
Engineering at Lovely Professional University (LPU).pdf
Sona
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S
Frankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkundeFrankfurt University of Applied Science urkunde
Frankfurt University of Applied Science urkunde
Lisa Emerson
only history of java.pptx real bihind the name java
only history of java.pptx real bihind the name javaonly history of java.pptx real bihind the name java
only history of java.pptx real bihind the name java
mushtaqsaliq9
autonomous vehicle project for engineering.pdf
autonomous vehicle project for engineering.pdfautonomous vehicle project for engineering.pdf
autonomous vehicle project for engineering.pdf
JyotiLohar6
Industrial Construction shed PEB MFG.pdf
Industrial Construction shed PEB MFG.pdfIndustrial Construction shed PEB MFG.pdf
Industrial Construction shed PEB MFG.pdf
PLINTH & ROOFS
How to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using ArduinoHow to Make an RFID Door Lock System using Arduino
How to Make an RFID Door Lock System using Arduino
CircuitDigest
Sachpazis: Foundation Analysis and Design: Single Piles
Sachpazis: Foundation Analysis and Design: Single PilesSachpazis: Foundation Analysis and Design: Single Piles
Sachpazis: Foundation Analysis and Design: Single Piles
Dr.Costas Sachpazis
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Gauges are a Pump's Best Friend - Troubleshooting and Operations - v.07
Brian Gongol
Lectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).pptLectureof nano 1588236675-biosensors (1).ppt
Lectureof nano 1588236675-biosensors (1).ppt
SherifElGohary7
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
Structural QA/QC Inspection in KRP 401600 | Copper Processing Plant-3 (MOF-3)...
slayshadow705
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
Syntax Directed Definitions  Synthesized Attributes  and  Inherited AttributesSyntax Directed Definitions  Synthesized Attributes  and  Inherited Attributes
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
GM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptxGM Meeting 070225 TO 130225 for 2024.pptx
GM Meeting 070225 TO 130225 for 2024.pptx
crdslalcomumbai
Industrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products ProfileIndustrial Valves, Instruments Products Profile
Industrial Valves, Instruments Products Profile
zebcoeng
Mathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptxMathematics_behind_machine_learning_INT255.pptx
Mathematics_behind_machine_learning_INT255.pptx
ppkmurthy2006
CS3451 INTRODUCTIONN TO OS unit ONE .pdf
CS3451 INTRODUCTIONN TO OS unit ONE .pdfCS3451 INTRODUCTIONN TO OS unit ONE .pdf
CS3451 INTRODUCTIONN TO OS unit ONE .pdf
PonniS7
TM-ASP-101-RF_Air Press manual crimping machine.pdf
TM-ASP-101-RF_Air Press manual crimping machine.pdfTM-ASP-101-RF_Air Press manual crimping machine.pdf
TM-ASP-101-RF_Air Press manual crimping machine.pdf
ChungLe60
Engineering at Lovely Professional University (LPU).pdf
Engineering at Lovely Professional University (LPU).pdfEngineering at Lovely Professional University (LPU).pdf
Engineering at Lovely Professional University (LPU).pdf
Sona
Cyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptxCyber Security_ Protecting the Digital World.pptx
Cyber Security_ Protecting the Digital World.pptx
Harshith A S

C PRESENTATION.pptx

  • 2. Arithmetic operators Assignment operators Relational operators Logical operators Bit wise operators Conditional operators (ternary operators) Increment/decrement operators Special operators. To study.
  • 3. The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators, functions, constants and variables are combined together to form expressions. Introduction
  • 4. Types of Operators Description Arithmetic Operators Perform mathematical calculations like addition, subtraction, multiplication, division and modulus Assignment Operators Assign the values for the variables in C programs. Relational operators Compare the value of two variables. Logical operators Perform logical operations on the given two variables. Bit wise operators Perform bit operations on given two variables. Conditional (ternary) operators Conditional operators return one value if condition is true and returns another value is condition is false. Increment/decrement operators Either increase or decrease the value of the variable by one. Special operators &, *, sizeof( ) and ternary operators. Types of C Operators
  • 5. Arithmetic Operators/Operatio n Example + (Addition) A+B (Subtraction) A-B * (multiplication) A*B / (Division) A/B % (Modulus) A%B ARITHMETIC OPERATORS IN C
  • 6. #include <stdio.h> int main() { int a=40,b=20, add,sub,mul,div,mod; add = a+b; sub = a-b; mul = a*b; div = a/b; mod = a%b; printf("Addition of a, b is : %dn", add); printf("Subtraction of a, b is : %dn", sub); printf("Multiplication of a, b is : %dn", mul); printf("Division of a, b is : %dn", div); printf("Modulus of a, b is : %dn", mod); return 0; } Example showing use of Arithmetic Operator
  • 7. Operators Example/Description = test = 10; 10 is assigned to variable test += test += 10; This is same as test = test + 10 -= test -= 10; This is same as test = test 10 *= test *= 10; This is same as test = test * 10 /= test /= 10; This is same as test = test / 10 %= test %= 10; This is same as test = test % 10 &= test&=10; This is same as test = test & 10 ^= test ^= 10; This is same as test = test ^ 10 ASSIGNMENT OPERATORS IN C
  • 8. # include <stdio.h> int main() { int Total=0,i; for(i=0;i<10;i++) { Total+=i; // This is same as Total = Toatal+i } printf("Total = %d", Total); return 0; } Example showing use of Assignment Operator
  • 9. Operators Example/Description > x > y (x is greater than y) < x < y (x is less than y) >= x >= y (x is greater than or equal to y) <= x <= y (x is less than or equal to y) == x == y (x is equal to y) != x != y (x is not equal to y) RELATIONAL OPERATORS IN C Relational operators are used to find the relation between two variables. i.e. to compare the values of two variables in a C program.
  • 10. #include <stdio.h> int main() { int m=40,n=20; if (m == n) { printf("m and n are equal"); } else { printf("m and n are not equal"); } return 0; } Example showing use of Relational Operator
  • 11. Operators Example/Description && (logical AND) (a>5)&&(b<5) It returns true when both conditions are true | | (logical OR) (a>=10)||(b>=10) It returns true when at-least one of the condition is true ! (logical NOT) !((a>5)&&(b<5)) It reverses the state of the operand ((a>5) && (b<5)) If ((a>5) && (b<5)) is true, logical NOT operator makes it false LOGICAL OPERATORS IN C
  • 12. #include <stdio.h> int main() { int m=40,n=20; int a=20,p=30; if (m>n && m !=0) { printf("&& Operator : Both conditions are truen"); } if (a>p | | p!=20) { printf("| | Operator : Only one condition is truen"); } if (!(m>n && m !=0)) { printf("! Operator : Both conditions are truen"); } else { printf("! Operator : Both conditions are true. " "But, status is inverted as falsen"); } return 0; } Example showing use of Logical Operator
  • 13. These operators are used to perform bit operations. Decimal values are converted into binary values which are the sequence of bits and bit wise operators work on these bits. Following are bitwise operator 1) & Bitwise AND 2 ) | Bitwise OR 3) ~ Bitwise NOT 4) ^ XOR 5) << Left Shift 6) >> Right Shift BIT WISE OPERATORS IN C
  • 14. #include <stdio.h> int main() { int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ; AND_opr = (m&n); OR_opr = (m|n); NOT_opr = (~m); XOR_opr = (m^n); printf("AND_opr value = %dn",AND_opr ); printf("OR_opr value = %dn",OR_opr ); printf("NOT_opr value = %dn",NOT_opr ); printf("XOR_opr value = %dn",XOR_opr ); printf("left_shift value = %dn", m << 1); printf("right_shift value = %dn", m >> 1); } Program showing Bitwise Operator in C
  • 15. Conditional operators return one value if condition is true and returns another value is condition is false. This operator is also called as ternary operator. Syntax : Example : (Condition? true_value: false_value); (A > 100 ? 0 : 1); CONDITIONAL OR TERNARY OPERATORS IN C
  • 16. #include <stdio.h> int main() { int x=1, y ; y = ( x ==1 ? 2 : 0 ) ; printf("x value is %dn", x); printf("y value is %d", y); return 0; } Program for use of Ternary Operator
  • 17. Increment operators are used to increase the value of the variable by one and decrement operators are used to decrease the value of the variable by one in C programs. Increment operator ++var_name; (or) var_name++; Decrement operator - -var_name; (or) var_name -; Increment /Decrement Operators
  • 18. #include <stdio.h> int main() { int i=1; while(i<10) { printf("%d ",i); i++; } return 0; } Example for increment operators
  • 19. #include <stdio.h> int main() { int i=1; while(i<10) { printf("%d ",i); i--; } return 0; } Example for Decrement operators
  • 20.