SlideShare a Scribd company logo
1 of 3
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

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Python operators part2
Python operators part2Python operators part2
Python operators part2Vishal Dutt
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++Praveen M Jigajinni
 
Operators in Python
Operators in PythonOperators in Python
Operators in PythonAnusuya123
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming Kamal Acharya
 
Operators in python
Operators in pythonOperators in python
Operators in pythoneShikshak
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 

What's hot (20)

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
C operators
C operatorsC operators
C operators
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Python operators part2
Python operators part2Python operators part2
Python operators part2
 
Opreator In "C"
Opreator In "C"Opreator In "C"
Opreator In "C"
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
Operator 04 (js)
Operator 04 (js)Operator 04 (js)
Operator 04 (js)
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 

Similar to C programming operators

Similar to C programming operators (20)

Opeartor &amp; expression
Opeartor &amp; expressionOpeartor &amp; expression
Opeartor &amp; expression
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
 
Data types and operators in vb
Data types and operators  in vbData types and operators  in vb
Data types and operators in vb
 
07 ruby operators
07 ruby operators07 ruby operators
07 ruby operators
 
Java script session 4
Java script session 4Java script session 4
Java script session 4
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
Python operators
Python operatorsPython operators
Python operators
 
Operators and it's type
Operators and it's type Operators and it's type
Operators and it's type
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Constructor and destructors
Constructor and destructorsConstructor and destructors
Constructor and destructors
 
Operators and Expression
Operators and ExpressionOperators and Expression
Operators and Expression
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 

More from Suneel Dogra

Distributed databases
Distributed databasesDistributed databases
Distributed databasesSuneel Dogra
 
Data base management system
Data base management systemData base management system
Data base management systemSuneel Dogra
 
Web sitedesignpart1
Web sitedesignpart1Web sitedesignpart1
Web sitedesignpart1Suneel Dogra
 
Web sitedesignpart1
Web sitedesignpart1Web sitedesignpart1
Web sitedesignpart1Suneel Dogra
 
He 12 different types of servers that every techie should know about
He 12 different types of servers that every techie should know aboutHe 12 different types of servers that every techie should know about
He 12 different types of servers that every techie should know aboutSuneel Dogra
 
Bachelor of computer application b.c.a.-2014
Bachelor of computer application b.c.a.-2014Bachelor of computer application b.c.a.-2014
Bachelor of computer application b.c.a.-2014Suneel Dogra
 
Cloud computing application
Cloud computing applicationCloud computing application
Cloud computing applicationSuneel Dogra
 
Fast track to linux
Fast track to linuxFast track to linux
Fast track to linuxSuneel Dogra
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array Suneel Dogra
 

More from Suneel Dogra (20)

Business model
Business modelBusiness model
Business model
 
Internet
InternetInternet
Internet
 
Html
HtmlHtml
Html
 
Dreamweaver
DreamweaverDreamweaver
Dreamweaver
 
Advanced html
Advanced htmlAdvanced html
Advanced html
 
Sql
SqlSql
Sql
 
File organisation
File organisationFile organisation
File organisation
 
Distributed databases
Distributed databasesDistributed databases
Distributed databases
 
Database models
Database models Database models
Database models
 
Data base management system
Data base management systemData base management system
Data base management system
 
Web sitedesignpart1
Web sitedesignpart1Web sitedesignpart1
Web sitedesignpart1
 
Web sitedesignpart1
Web sitedesignpart1Web sitedesignpart1
Web sitedesignpart1
 
Internet security
Internet securityInternet security
Internet security
 
What is the linux
What is the linuxWhat is the linux
What is the linux
 
He 12 different types of servers that every techie should know about
He 12 different types of servers that every techie should know aboutHe 12 different types of servers that every techie should know about
He 12 different types of servers that every techie should know about
 
Bachelor of computer application b.c.a.-2014
Bachelor of computer application b.c.a.-2014Bachelor of computer application b.c.a.-2014
Bachelor of computer application b.c.a.-2014
 
Cloud computing application
Cloud computing applicationCloud computing application
Cloud computing application
 
Fast track to linux
Fast track to linuxFast track to linux
Fast track to linux
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array
 
String in c
String in cString in c
String in c
 

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(); }