SlideShare a Scribd company logo
C Programming Operators
Operators are the symbol which operates on value or a variable. For example: + is a
operator to perform addition.C programming language has wide range of operators to
perform various operations.Simple answer can be given using expression 4 + 5 is
equal to 9. Here 4 and 5 are called operands and + is called operator. C language
supports following type of operators.
• Arithmetic Operators
• Logical (or Relational) Operators
• Bitwise Operators
• Assignment Operators
• Misc Operators
Arithmetic Operators
Operator Description Example
+ Adds two operands A + B will give 30
- Subtracts second operand from the first A - B will give -10
* Multiply both operands A * B will give 200
/ Divide numerator by denumerator B / A will give 2
% Modulus Operator and remainder of after an integer division B % A will give 0
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g;
clrscr();
printf("Enter the value of A");
scanf("%d",&a);
printf("Enter the value of B");
scanf("%d",&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
printf("nThe Sum of A and B is%d",c);
printf("nThe Sub of A and B is%d",d);
printf("nThe Multiply of A and B is%d",e);
printf("nThe Divide of A and B is%d",f);
printf("nThe Modulus of A and B is%d",g);
getch();
}
Relational operators
Relational operators are used to compare, logical, arithmetic and character
expression. Each of these six relational operators takes two operands. Each of these
operators compares their left side with their right side. The whole expression
involving the relation operator then evaluate to an integer. It evaluates to 0 if the
condition is false and 1 if it is true.
Suppose that a and b are integer variables whose values are 100 and 4, respectively.
Several arithmetic expressions involving these variables are shown below, together
with their resulting values.
Expression Interpretation Value
a<b False 0
a>b True 1
a<=b False 0
a>=b True 1
a==b False 0
a!=b True 1
Assume variable A holds 10 and variable B holds 20 then:
Operator Description Example
==
Checks if the value of two operands is equal or not, if
yes then condition becomes true.
(A == B) is not true.
!=
Checks if the value of two operands is equal or not, if
values are not equal then condition becomes true.
(A != B) is true.
>
Checks if the value of left operand is greater than the
value of right operand, if yes then condition becomes
true.
(A > B) is not true.
<
Checks if the value of left operand is less than the value
of right operand, if yes then condition becomes true.
(A < B) is true.
>=
Checks if the value of left operand is greater than or
equal to the value of right operand, if yes then condition
becomes true.
(A >= B) is not true.
<=
Checks if the value of left operand is less than or equal
to the value of right operand, if yes then condition
becomes true.
(A <= B) is true.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the value of A:");
scanf("%d",&a);
printf("Enter the value of B:");
scanf("%d",&b);
printf("nThe output of A<B is%d",a<b);
printf("nThe output of A>B is%d",a>b);
printf("nThe output of A<=B is%d",a<=b);
printf("nThe output of A>=B is%d",a>=b);
getch();
}
C programming operators

More Related Content

What's hot (19)

PPTX
Operator.ppt
Darshan Patel
 
PDF
Java basic operators
Emmanuel Alimpolos
 
PPT
C operator and expression
LavanyaManokaran
 
PPTX
C operators
Rupanshi rawat
 
PPT
Operation and expression in c++
Online
 
PPTX
Python operators part2
Vishal Dutt
 
PPTX
Opreator In "C"
Amlendu dubey
 
PPT
Operator & Expression in c++
bajiajugal
 
PPTX
Operators and Expressions
Munazza-Mah-Jabeen
 
PPTX
Operator 04 (js)
AbhishekMondal42
 
PPT
Operators and Expressions in C++
Praveen M Jigajinni
 
PPT
Arithmetic operator
Jordan Delacruz
 
PPTX
Operators in C & C++ Language
PreSolutions Softwares
 
PPTX
Operators in Python
Anusuya123
 
PPTX
Expression and Operartor In C Programming
Kamal Acharya
 
PPT
C Sharp Jn (2)
guest58c84c
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PDF
Operators in python
eShikshak
 
PPT
Operators in c language
Amit Singh
 
Operator.ppt
Darshan Patel
 
Java basic operators
Emmanuel Alimpolos
 
C operator and expression
LavanyaManokaran
 
C operators
Rupanshi rawat
 
Operation and expression in c++
Online
 
Python operators part2
Vishal Dutt
 
Opreator In "C"
Amlendu dubey
 
Operator & Expression in c++
bajiajugal
 
Operators and Expressions
Munazza-Mah-Jabeen
 
Operator 04 (js)
AbhishekMondal42
 
Operators and Expressions in C++
Praveen M Jigajinni
 
Arithmetic operator
Jordan Delacruz
 
Operators in C & C++ Language
PreSolutions Softwares
 
Operators in Python
Anusuya123
 
Expression and Operartor In C Programming
Kamal Acharya
 
C Sharp Jn (2)
guest58c84c
 
6 operators-in-c
Rohit Shrivastava
 
Operators in python
eShikshak
 
Operators in c language
Amit Singh
 

Similar to C programming operators (20)

PPTX
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
PPTX
C operators
AbiramiT9
 
PDF
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
PPTX
PROGRAMMING IN C - Operators.pptx
Nithya K
 
DOCX
Programming Fundamentals lecture 7
REHAN IJAZ
 
PDF
C Operators and Control Structures.pdf
MaryJacob24
 
PDF
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
DOCX
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
 
PPTX
C Operators and Control Structures.pptx
ramanathan2006
 
DOCX
C – operators and expressions
Chukka Nikhil Chakravarthy
 
PPTX
COM1407: C Operators
Hemantha Kulathilake
 
PPT
Lecture 7- Operators and Expressions
Md. Imran Hossain Showrov
 
PPTX
Structured Programming Unit-4-Operators-and-Expression.pptx
SuryaBasnet1
 
PPTX
Operators and it's type
Asheesh kushwaha
 
PPTX
Expressions using operator in c
Saranya saran
 
PPTX
3. C_OperatorsExpressions on c languyage.pptx
iramulittihad
 
PDF
introduction to c programming - Topic 3.pdf
rajd20284
 
PPTX
C programming Tutorial Session 3
Muhammad Ehtisham Siddiqui
 
PPTX
C programming Tutorial Session 4
Muhammad Ehtisham Siddiqui
 
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
C operators
AbiramiT9
 
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
PROGRAMMING IN C - Operators.pptx
Nithya K
 
Programming Fundamentals lecture 7
REHAN IJAZ
 
C Operators and Control Structures.pdf
MaryJacob24
 
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
 
C Operators and Control Structures.pptx
ramanathan2006
 
C – operators and expressions
Chukka Nikhil Chakravarthy
 
COM1407: C Operators
Hemantha Kulathilake
 
Lecture 7- Operators and Expressions
Md. Imran Hossain Showrov
 
Structured Programming Unit-4-Operators-and-Expression.pptx
SuryaBasnet1
 
Operators and it's type
Asheesh kushwaha
 
Expressions using operator in c
Saranya saran
 
3. C_OperatorsExpressions on c languyage.pptx
iramulittihad
 
introduction to c programming - Topic 3.pdf
rajd20284
 
C programming Tutorial Session 3
Muhammad Ehtisham Siddiqui
 
C programming Tutorial Session 4
Muhammad Ehtisham Siddiqui
 
Ad

More from Suneel Dogra (20)

PPT
Business model
Suneel Dogra
 
PDF
Internet
Suneel Dogra
 
PDF
Html
Suneel Dogra
 
PDF
Dreamweaver
Suneel Dogra
 
PDF
Advanced html
Suneel Dogra
 
PDF
Sql
Suneel Dogra
 
PDF
File organisation
Suneel Dogra
 
PDF
Distributed databases
Suneel Dogra
 
PDF
Database models
Suneel Dogra
 
PDF
Data base management system
Suneel Dogra
 
PPT
Web sitedesignpart1
Suneel Dogra
 
PPT
Web sitedesignpart1
Suneel Dogra
 
PPT
Internet security
Suneel Dogra
 
PDF
What is the linux
Suneel Dogra
 
DOC
He 12 different types of servers that every techie should know about
Suneel Dogra
 
PDF
Bachelor of computer application b.c.a.-2014
Suneel Dogra
 
DOC
Cloud computing application
Suneel Dogra
 
DOC
Fast track to linux
Suneel Dogra
 
DOC
A sorted linear array
Suneel Dogra
 
DOC
String in c
Suneel Dogra
 
Business model
Suneel Dogra
 
Internet
Suneel Dogra
 
Dreamweaver
Suneel Dogra
 
Advanced html
Suneel Dogra
 
File organisation
Suneel Dogra
 
Distributed databases
Suneel Dogra
 
Database models
Suneel Dogra
 
Data base management system
Suneel Dogra
 
Web sitedesignpart1
Suneel Dogra
 
Web sitedesignpart1
Suneel Dogra
 
Internet security
Suneel Dogra
 
What is the linux
Suneel Dogra
 
He 12 different types of servers that every techie should know about
Suneel Dogra
 
Bachelor of computer application b.c.a.-2014
Suneel Dogra
 
Cloud computing application
Suneel Dogra
 
Fast track to linux
Suneel Dogra
 
A sorted linear array
Suneel Dogra
 
String in c
Suneel Dogra
 
Ad

C programming operators

  • 1. C Programming Operators Operators are the symbol which operates on value or a variable. For example: + is a operator to perform addition.C programming language has wide range of operators to perform various operations.Simple answer can be given using expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and + is called operator. C language supports following type of operators. • Arithmetic Operators • Logical (or Relational) Operators • Bitwise Operators • Assignment Operators • Misc Operators Arithmetic Operators Operator Description Example + Adds two operands A + B will give 30 - Subtracts second operand from the first A - B will give -10 * Multiply both operands A * B will give 200 / Divide numerator by denumerator B / A will give 2 % Modulus Operator and remainder of after an integer division B % A will give 0 #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e,f,g; clrscr(); printf("Enter the value of A"); scanf("%d",&a); printf("Enter the value of B"); scanf("%d",&b); c=a+b; d=a-b; e=a*b; f=a/b; g=a%b; printf("nThe Sum of A and B is%d",c); printf("nThe Sub of A and B is%d",d); printf("nThe Multiply of A and B is%d",e); printf("nThe Divide of A and B is%d",f); printf("nThe Modulus of A and B is%d",g); getch(); } Relational operators Relational operators are used to compare, logical, arithmetic and character expression. Each of these six relational operators takes two operands. Each of these
  • 2. operators compares their left side with their right side. The whole expression involving the relation operator then evaluate to an integer. It evaluates to 0 if the condition is false and 1 if it is true. Suppose that a and b are integer variables whose values are 100 and 4, respectively. Several arithmetic expressions involving these variables are shown below, together with their resulting values. Expression Interpretation Value a<b False 0 a>b True 1 a<=b False 0 a>=b True 1 a==b False 0 a!=b True 1 Assume variable A holds 10 and variable B holds 20 then: Operator Description Example == Checks if the value of two operands is equal or not, if yes then condition becomes true. (A == B) is not true. != Checks if the value of two operands is equal or not, if values are not equal then condition becomes true. (A != B) is true. > Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (A > B) is not true. < Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. (A < B) is true. >= Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (A >= B) is not true. <= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (A <= B) is true. #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter the value of A:"); scanf("%d",&a); printf("Enter the value of B:"); scanf("%d",&b); printf("nThe output of A<B is%d",a<b); printf("nThe output of A>B is%d",a>b); printf("nThe output of A<=B is%d",a<=b); printf("nThe output of A>=B is%d",a>=b); getch(); }