SlideShare a Scribd company logo
1 of 30
COMPUTER PROGRAMING AND UTILIZATION
By Kaushal Patel
TYPES OF OPERATORS
Operators are the verbs of a language that help
the user perform computations on values.
“An operator is a symbol (+,-,*,/) that directs the computer to
perform certain mathematical or logical manipulations and is
usually used to manipulate data and variables”
Ex: a + b
Definition
2
Operators in C
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and decrement operators
6. Conditional operators
7. Bitwise operators
8. Special operators
3
Arithmetic operators
Arithmetic operators are used to perform arithmetic
operations. ‘C’ language supports following arithmetic
operators.
Operator example Meaning
+ a + b Addition –unary
- a – b Subtraction- unary
* a * b Multiplication
/ a / b Division
% a % b Modulo division-
remainder
4
 The ‘C’ language does not provide the operator for exponentiation.
+ and – operator can be used as unary operator also. Except %
operator all arithmetic can be used with any type of numeric
operands, while % operator can only be used with integer data type
only.
 Following program will clarify how arithmetic operators behave
with different data type, particularly the use of /and % operator.
Arithmetic operators
5
Example:-
# include<stdio.h>
main()
{
int x=25;
int y=4;
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);
printf(“%d%%d=%dn” ,x, y, x%y);
}
Arithmetic operators
6
Output:-
25+4 =29
25-4=21
25*4=100
25/4=6
25%4=1
Arithmetic operators
7
Explanation:
First three operations are obvious. The division
operation gives the answer 6 because, the variables x and
y are integer variables, when we use / with integer
operands the result will be integer number.
while,%operator produce the remainder after division of
25by 4.
Arithmetic operators
8
Assignment Operators
 We have already used the assignment operator = in previous
programs ‘C’ language supports = assignment operator. It is used
to assign a value to a variable. The syntax is
variablename = expression
 The expression can be a constant, variable name or any valid
expression.
 ‘C’ also supports the use of shorthand notation also.
form is
variable = varname operator expression;
into
varname operator = expression;
9
Assignment Operators
 Use of shorthand notation makes your statement
concise and program writing becomes faster when
variable name are long in size
Assignment Operator Shorthand
a = a + 5; a += 5;
a = a – 5; a -= 5;
a = a * 5; a *= 5;
a = a /5; a /= 5;
a = a % 5(assuming a as integer) a %= 5;
10
Assignment Operators
 Example:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf(“Give the value of an”);
scanf(“%d”,&a);
a += 5;
printf(“a= %dn”,a);
a -= 5;
printf (“a =%dn”,a);
getch();
}
11
Assignment Operators
 Output:-
Give the value of a
4
a =9
a =4
12
Logical Operators
 Sometimes in programming, we need to take certain
action if some condition are true or false. Logical
operators help us to combine more than one conditions,
and based on the outcome certain steps are taken.
Operator name Meaning
&& Logical AND
|| Logical OR
! Logical NOT(Negation)
13
Logical Operators
 Logical NOT is an unary operator. In an expression, we can use more then
on logical operation. If more then one operator is used, !(NOT) is
evaluated first, then &&(AND) and then ||(OR), we can use parentheses to
change the order of evaluation.
for example, if we have a = 2, b = 3 and c = 5 then,
Expression Value Remark
a <b && c ==5 True Both expression are true
! (5 >3) False 5>3 is true & negation of
true is false
a< b || c=10 True a<b is true which makes
the expression true
(b> a) && (c !=5) False c =5, s0 second
condition false
(b<c || b>a) && (c==5) True Both sub expression are
true
14
Increment & Decrement Operators
C supports 2 useful operators namely
1. Increment (++)
2. Decrement(--)operators
The (++) operator adds a value 1 to the operand
The (--) operator subtracts 1 from the operand
(++a) or (a++)
(--a) or (a--)
15
Examples for (++) &(--) operators:-
Let the value of a =5 and b=++a then
a = b =6
Let the value of a = 5 and b=a++ then
a =5 but b=6
i.e.:
1. a prefix operator first adds 1 to the operand and then the result is
assigned to the variable on the left
ex:- (++a)or (--a) is called prefix increment or decrement
2. a postfix operator first assigns the value to the variable on left and
then increments the operand.
ex:- (a++)or (a--) is called postfix increment or decrement
Increment & Decrement Operators
16
If the ++ or – operator is used in an expression or
assignment then prefix notation give different values.
Ones should use prefix notation carefully in an
assignment or expression involving other variables.
Increment & Decrement Operators
17
Example:-
#include <stdio.h>
#include <conio.h>
main()
{
int x=10;
int y;
int z=0;
clrscr();
x++;
++x;
y=++x;
printf(“ Value of x=%d y=%d and z-%dn”, x,y,z);
z=y--;
printf(“ Value of x=%d y=%d and z-%dn”, x,y,z);
}
Increment & Decrement Operators
18
Output:-
Value of x=13 y=13 and z=0
Value of x=13 y=12 and z=13
Increment & Decrement Operators
19
C language has two useful operators called increment(++) and decrement
(--) that operate on integer data only.
The increment (++) operator increments the operand by 1, while the decrement
operator (--) decrements the operand by 1, for example ,:
int i , j;
i = 10;
j = i++ ;
printf(“ %d %d “, i, j);
OUTPUT:-
11 10 . First i is assigned to j and then i is incremented by 1
Increment & Decrement Operators
20
If we have :
int i, j ;
I = 20;
j = ++i;
printf(“%d %d”, i, j);
OUTPUT :
first i is incremented by 1 and then assignment take place i.e., pre- increment of i.
now, consider the example for (--) operator :
int a, b;
a=10;
b= a--;
printf(“%d %d”, a , b)
OUTPUT :
first a is assigned to b then a is decremented by 1. i.e.,post decrement takes place
Increment & Decrement Operators
21
Decrement Operator:-
If we have : int i, j ;
I = 20;
j = --i;
printf(“%d %d”, i, j);
OUTPUT : 19 19. first i is decremented by 1 and then assignment
take place i.e., pre-decrement of i.
Note : on some compilers a space is required on both sides of ++I or i++ ,
i-- or --i
Increment & Decrement Operators
22
Bitwise Operators
 We know that internally, the data is represented in
bits 0 and 1. ‘C’ language supports some operators
which can perform at the bit level. These type of
operations are normally done in assembly or
machine level programming. But, ‘C’ language
supports bit level manipulation also, that is why ‘C’
language is also known as middle-level programming
language.
23
Bitwise Operators
 Following table shows bit-wise operators with their
meaning:
Operator name Meaning
& Bit-wise AND
| Bit-wise OR
^ Bit-wise Exclusive OR(XOR)
<< Left Shift
>> Right Shift
- Bit-wise 1’s component
24
Bitwise Operators
 Examples:-
#include<stdio.h>
#include<conio.h>
Void main()
{
int x;
int mul,div;
clrscr();
printf(“Give one integer numbern”);
scanf(“%d”,&x);
mul = x << 1; /* left shift */
div = x >> 1; /* right shift */
printf(“multiplication of %d by 2 = %dn”,x,mul);
scanf(“division of %d by 2 = %dn”,x,div);
}
25
Bitwise Operators
 Output:-
Give one integer number
5
multiplication of 5 by 2 = 10
Division of by 2 = 2
26
Other Special Operators
 ‘C’ language provides other special operator. They
are:
Comma operator
sizeof operator
Arrow(->) operator
dot operator
* operator and & operator
27
Other Special Operators
 Comma operator:-
(,) Comma operator is used to combine multiple statements.
It is used to separate multiple expressions. It has the lowest
precedence. It is mainly used in for loop.
The expressions which are separated by comma operator
are evaluated from left to right.
For example, the following statement
z = (x=5, x+5);
is equivalent to the statement sequence
x = 5;
z = x+5;
28
Other Special Operators
 sizeof operator:-
sizeof operator is used to find our the storage requirement
of an operand in memory. It is an unary operator which
returns size in bytes.
The syntax is sizeof(operand)
For example,
sizeof(float) returns the value 4
sizeof(int) return the value 2
The statement sequence,
char c;
sizeof(c);
will return the value 1, because c is character type variable.
29
THANK YOU
30

More Related Content

What's hot (20)

FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 
Operators
OperatorsOperators
Operators
 
Basic concepts of oops
Basic concepts of oopsBasic concepts of oops
Basic concepts of oops
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
Programming style - duck type
Programming style - duck typeProgramming style - duck type
Programming style - duck type
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Pass Structure of Assembler
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
Spm unit 1
Spm unit 1Spm unit 1
Spm unit 1
 
Pointer to function 2
Pointer to function 2Pointer to function 2
Pointer to function 2
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 

Similar to Operators-computer programming and utilzation

PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxNithya K
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdfMaryJacob24
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptxramanathan2006
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++sunny khan
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsAmrinder Sidhu
 
Programming presentation
Programming presentationProgramming presentation
Programming presentationFiaz Khokhar
 
Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Ibrahim Elewah
 

Similar to Operators-computer programming and utilzation (20)

Theory3
Theory3Theory3
Theory3
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
Operators
OperatorsOperators
Operators
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Computer programming chapter ( 4 )
Computer programming chapter ( 4 )
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 

More from Kaushal Patel

5 amazing monuments of ancient india
5 amazing monuments of ancient india5 amazing monuments of ancient india
5 amazing monuments of ancient indiaKaushal Patel
 
Simple vapour compression system
Simple vapour compression systemSimple vapour compression system
Simple vapour compression systemKaushal Patel
 
Regenerative and reduced air refrigeration system
Regenerative and reduced air refrigeration  systemRegenerative and reduced air refrigeration  system
Regenerative and reduced air refrigeration systemKaushal Patel
 
Gear manufacturing methods
Gear manufacturing methodsGear manufacturing methods
Gear manufacturing methodsKaushal Patel
 
Combustion Chamber for Compression Ignition Engines
Combustion Chamber for Compression Ignition EnginesCombustion Chamber for Compression Ignition Engines
Combustion Chamber for Compression Ignition EnginesKaushal Patel
 
Time response analysis
Time response analysisTime response analysis
Time response analysisKaushal Patel
 
Tracing of cartesian curve
Tracing of cartesian curveTracing of cartesian curve
Tracing of cartesian curveKaushal Patel
 
simple casestudy on building materials
simple casestudy on building materialssimple casestudy on building materials
simple casestudy on building materialsKaushal Patel
 
linear tranformation- VC&LA
linear tranformation- VC&LAlinear tranformation- VC&LA
linear tranformation- VC&LAKaushal Patel
 
Broching machine-manufacturing process-1
Broching machine-manufacturing process-1Broching machine-manufacturing process-1
Broching machine-manufacturing process-1Kaushal Patel
 
Case study 2 storke-elements of mechanical engineering
Case study 2 storke-elements of mechanical engineeringCase study 2 storke-elements of mechanical engineering
Case study 2 storke-elements of mechanical engineeringKaushal Patel
 
Methods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsMethods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsKaushal Patel
 
Drilling machines-manufacturing process-1
Drilling machines-manufacturing process-1Drilling machines-manufacturing process-1
Drilling machines-manufacturing process-1Kaushal Patel
 
Stress and strain- mechanics of solid
Stress and strain- mechanics of solidStress and strain- mechanics of solid
Stress and strain- mechanics of solidKaushal Patel
 
Engineering thermodynemics-difference between heat and work
Engineering thermodynemics-difference between heat and workEngineering thermodynemics-difference between heat and work
Engineering thermodynemics-difference between heat and workKaushal Patel
 
Nano science _technology
Nano science _technologyNano science _technology
Nano science _technologyKaushal Patel
 
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERING
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERINGCochran Boiler-ELEMENTS OF MECHANICAL ENGINEERING
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERINGKaushal Patel
 

More from Kaushal Patel (19)

5 amazing monuments of ancient india
5 amazing monuments of ancient india5 amazing monuments of ancient india
5 amazing monuments of ancient india
 
Simple vapour compression system
Simple vapour compression systemSimple vapour compression system
Simple vapour compression system
 
Regenerative and reduced air refrigeration system
Regenerative and reduced air refrigeration  systemRegenerative and reduced air refrigeration  system
Regenerative and reduced air refrigeration system
 
Gear manufacturing methods
Gear manufacturing methodsGear manufacturing methods
Gear manufacturing methods
 
Combustion Chamber for Compression Ignition Engines
Combustion Chamber for Compression Ignition EnginesCombustion Chamber for Compression Ignition Engines
Combustion Chamber for Compression Ignition Engines
 
Elliptical trammel
Elliptical trammelElliptical trammel
Elliptical trammel
 
Time response analysis
Time response analysisTime response analysis
Time response analysis
 
Tracing of cartesian curve
Tracing of cartesian curveTracing of cartesian curve
Tracing of cartesian curve
 
simple casestudy on building materials
simple casestudy on building materialssimple casestudy on building materials
simple casestudy on building materials
 
linear tranformation- VC&LA
linear tranformation- VC&LAlinear tranformation- VC&LA
linear tranformation- VC&LA
 
Broching machine-manufacturing process-1
Broching machine-manufacturing process-1Broching machine-manufacturing process-1
Broching machine-manufacturing process-1
 
Case study 2 storke-elements of mechanical engineering
Case study 2 storke-elements of mechanical engineeringCase study 2 storke-elements of mechanical engineering
Case study 2 storke-elements of mechanical engineering
 
Methods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsMethods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematics
 
Drilling machines-manufacturing process-1
Drilling machines-manufacturing process-1Drilling machines-manufacturing process-1
Drilling machines-manufacturing process-1
 
Stress and strain- mechanics of solid
Stress and strain- mechanics of solidStress and strain- mechanics of solid
Stress and strain- mechanics of solid
 
Engineering thermodynemics-difference between heat and work
Engineering thermodynemics-difference between heat and workEngineering thermodynemics-difference between heat and work
Engineering thermodynemics-difference between heat and work
 
Types of cables
Types of cablesTypes of cables
Types of cables
 
Nano science _technology
Nano science _technologyNano science _technology
Nano science _technology
 
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERING
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERINGCochran Boiler-ELEMENTS OF MECHANICAL ENGINEERING
Cochran Boiler-ELEMENTS OF MECHANICAL ENGINEERING
 

Recently uploaded

PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilVinayVitekari
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...jabtakhaidam7
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 

Recently uploaded (20)

PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 

Operators-computer programming and utilzation

  • 1. COMPUTER PROGRAMING AND UTILIZATION By Kaushal Patel TYPES OF OPERATORS
  • 2. Operators are the verbs of a language that help the user perform computations on values. “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations and is usually used to manipulate data and variables” Ex: a + b Definition 2
  • 3. Operators in C 1. Arithmetic operators 2. Relational operators 3. Logical operators 4. Assignment operators 5. Increment and decrement operators 6. Conditional operators 7. Bitwise operators 8. Special operators 3
  • 4. Arithmetic operators Arithmetic operators are used to perform arithmetic operations. ‘C’ language supports following arithmetic operators. Operator example Meaning + a + b Addition –unary - a – b Subtraction- unary * a * b Multiplication / a / b Division % a % b Modulo division- remainder 4
  • 5.  The ‘C’ language does not provide the operator for exponentiation. + and – operator can be used as unary operator also. Except % operator all arithmetic can be used with any type of numeric operands, while % operator can only be used with integer data type only.  Following program will clarify how arithmetic operators behave with different data type, particularly the use of /and % operator. Arithmetic operators 5
  • 6. Example:- # include<stdio.h> main() { int x=25; int y=4; 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); printf(“%d%%d=%dn” ,x, y, x%y); } Arithmetic operators 6
  • 8. Explanation: First three operations are obvious. The division operation gives the answer 6 because, the variables x and y are integer variables, when we use / with integer operands the result will be integer number. while,%operator produce the remainder after division of 25by 4. Arithmetic operators 8
  • 9. Assignment Operators  We have already used the assignment operator = in previous programs ‘C’ language supports = assignment operator. It is used to assign a value to a variable. The syntax is variablename = expression  The expression can be a constant, variable name or any valid expression.  ‘C’ also supports the use of shorthand notation also. form is variable = varname operator expression; into varname operator = expression; 9
  • 10. Assignment Operators  Use of shorthand notation makes your statement concise and program writing becomes faster when variable name are long in size Assignment Operator Shorthand a = a + 5; a += 5; a = a – 5; a -= 5; a = a * 5; a *= 5; a = a /5; a /= 5; a = a % 5(assuming a as integer) a %= 5; 10
  • 11. Assignment Operators  Example:- #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf(“Give the value of an”); scanf(“%d”,&a); a += 5; printf(“a= %dn”,a); a -= 5; printf (“a =%dn”,a); getch(); } 11
  • 12. Assignment Operators  Output:- Give the value of a 4 a =9 a =4 12
  • 13. Logical Operators  Sometimes in programming, we need to take certain action if some condition are true or false. Logical operators help us to combine more than one conditions, and based on the outcome certain steps are taken. Operator name Meaning && Logical AND || Logical OR ! Logical NOT(Negation) 13
  • 14. Logical Operators  Logical NOT is an unary operator. In an expression, we can use more then on logical operation. If more then one operator is used, !(NOT) is evaluated first, then &&(AND) and then ||(OR), we can use parentheses to change the order of evaluation. for example, if we have a = 2, b = 3 and c = 5 then, Expression Value Remark a <b && c ==5 True Both expression are true ! (5 >3) False 5>3 is true & negation of true is false a< b || c=10 True a<b is true which makes the expression true (b> a) && (c !=5) False c =5, s0 second condition false (b<c || b>a) && (c==5) True Both sub expression are true 14
  • 15. Increment & Decrement Operators C supports 2 useful operators namely 1. Increment (++) 2. Decrement(--)operators The (++) operator adds a value 1 to the operand The (--) operator subtracts 1 from the operand (++a) or (a++) (--a) or (a--) 15
  • 16. Examples for (++) &(--) operators:- Let the value of a =5 and b=++a then a = b =6 Let the value of a = 5 and b=a++ then a =5 but b=6 i.e.: 1. a prefix operator first adds 1 to the operand and then the result is assigned to the variable on the left ex:- (++a)or (--a) is called prefix increment or decrement 2. a postfix operator first assigns the value to the variable on left and then increments the operand. ex:- (a++)or (a--) is called postfix increment or decrement Increment & Decrement Operators 16
  • 17. If the ++ or – operator is used in an expression or assignment then prefix notation give different values. Ones should use prefix notation carefully in an assignment or expression involving other variables. Increment & Decrement Operators 17
  • 18. Example:- #include <stdio.h> #include <conio.h> main() { int x=10; int y; int z=0; clrscr(); x++; ++x; y=++x; printf(“ Value of x=%d y=%d and z-%dn”, x,y,z); z=y--; printf(“ Value of x=%d y=%d and z-%dn”, x,y,z); } Increment & Decrement Operators 18
  • 19. Output:- Value of x=13 y=13 and z=0 Value of x=13 y=12 and z=13 Increment & Decrement Operators 19
  • 20. C language has two useful operators called increment(++) and decrement (--) that operate on integer data only. The increment (++) operator increments the operand by 1, while the decrement operator (--) decrements the operand by 1, for example ,: int i , j; i = 10; j = i++ ; printf(“ %d %d “, i, j); OUTPUT:- 11 10 . First i is assigned to j and then i is incremented by 1 Increment & Decrement Operators 20
  • 21. If we have : int i, j ; I = 20; j = ++i; printf(“%d %d”, i, j); OUTPUT : first i is incremented by 1 and then assignment take place i.e., pre- increment of i. now, consider the example for (--) operator : int a, b; a=10; b= a--; printf(“%d %d”, a , b) OUTPUT : first a is assigned to b then a is decremented by 1. i.e.,post decrement takes place Increment & Decrement Operators 21
  • 22. Decrement Operator:- If we have : int i, j ; I = 20; j = --i; printf(“%d %d”, i, j); OUTPUT : 19 19. first i is decremented by 1 and then assignment take place i.e., pre-decrement of i. Note : on some compilers a space is required on both sides of ++I or i++ , i-- or --i Increment & Decrement Operators 22
  • 23. Bitwise Operators  We know that internally, the data is represented in bits 0 and 1. ‘C’ language supports some operators which can perform at the bit level. These type of operations are normally done in assembly or machine level programming. But, ‘C’ language supports bit level manipulation also, that is why ‘C’ language is also known as middle-level programming language. 23
  • 24. Bitwise Operators  Following table shows bit-wise operators with their meaning: Operator name Meaning & Bit-wise AND | Bit-wise OR ^ Bit-wise Exclusive OR(XOR) << Left Shift >> Right Shift - Bit-wise 1’s component 24
  • 25. Bitwise Operators  Examples:- #include<stdio.h> #include<conio.h> Void main() { int x; int mul,div; clrscr(); printf(“Give one integer numbern”); scanf(“%d”,&x); mul = x << 1; /* left shift */ div = x >> 1; /* right shift */ printf(“multiplication of %d by 2 = %dn”,x,mul); scanf(“division of %d by 2 = %dn”,x,div); } 25
  • 26. Bitwise Operators  Output:- Give one integer number 5 multiplication of 5 by 2 = 10 Division of by 2 = 2 26
  • 27. Other Special Operators  ‘C’ language provides other special operator. They are: Comma operator sizeof operator Arrow(->) operator dot operator * operator and & operator 27
  • 28. Other Special Operators  Comma operator:- (,) Comma operator is used to combine multiple statements. It is used to separate multiple expressions. It has the lowest precedence. It is mainly used in for loop. The expressions which are separated by comma operator are evaluated from left to right. For example, the following statement z = (x=5, x+5); is equivalent to the statement sequence x = 5; z = x+5; 28
  • 29. Other Special Operators  sizeof operator:- sizeof operator is used to find our the storage requirement of an operand in memory. It is an unary operator which returns size in bytes. The syntax is sizeof(operand) For example, sizeof(float) returns the value 4 sizeof(int) return the value 2 The statement sequence, char c; sizeof(c); will return the value 1, because c is character type variable. 29