SlideShare a Scribd company logo
Gujarat Power Engineering 
& Research Institute 
PREPAREDBy-Shah Viraj
TOPIC:- C Operators
C Operators and Some
Differences
Contents
Operator:
•Arithmetic Operators
•Increment & Decrement Operators
•Special Operators
•Conditional Operators
Difference:
•Data and Information
•Compiler and Interpreter
•System software and Application Software
•Algorithm and Flowchart
•Array and Structure
•Call by Value and Call by Reference
 Operators are symbols which take one or more
operands or expressions and perform arithmetic or
logical computations. 
 Operands are variables or expressions which are
used in conjunction with operators to evaluate the
expression.
 Combination of operands and operators form an
expression. 
OPERATORS
Expressions
Combination of Operators and Operands
Example 2 * y + 5
Operands
Operators
TYPES OF OPERATORS
-C language provides following operators:-
Arithmetic Operators
o As the name is given, arithmetic operators perform
arithmetic operations.
o C language provides following arithmetic operators.
Operator name  Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus(Reminder after division)
ARITHMETIC OPERATORS
o These are “Binary Operators” as they take two
operands.
o The operands must be ”Numeric Value”.
o When both the operands are integer , then the
result is integer. But when one of them is floating
point and other is integer then the result is floating
point.
oExcept “% ” operators, all the arithmetic operators
can be used with any type of numeric operands(either
operands are integer or floating point), while “%”
operator can only be used with integer data type only.
SMALL EXAMPLE TO ILLUSTRATE THE 
USE OFARITHMETIC OPERATORS
#include<stdio.h>
#include<conio.h>
Void main()
{
float a=4,b=2,sum,sub,mul,div;
clrscr();
sum=a+b;
sub=a-b;
mul=a*b;
div=a/b;
printf(“summation of a and b=%fnsubtractionof and b=
%fnmultiplicationof and b=%fndivision of a and b=
%f,sum,sub,mul,div”);
getch();
}
Output of the following code will be like this:
summation of a and b=6.000000
subtraction of a and b=2.000000
multiplication of a and b=8.000000
division of a and b=2.000000
CONDITIONAL OPERATORS
o C language provides “?” operator as a conditional
operator.
o These are “Ternary Operators” as they take three
operands.
oIt is used as shown below:
Syntax:
Condition ? Expression1 : Expression2
-The statement above is equivalent to:
if (Condition)
Expression1
else
Expression2
o The operator “?” works as follows:
o Expression1 is evaluated first. If it is
nonzero(true), then the expression2 is evaluated and
becomes the value of the expression.
o If expression1 is false, expression3 is evaluated
and its value becomes the value of the expression.
o It is to be noted that only one of the
expression(either expression2 or expression3) is
evaluated.
o Hence, there is no dought that ternary operators
are the alternative use of “if..else” statement.
CONDITIONAL OPERATORS
Example 1:
if/else statement:
if (total > 60)
grade = ‘P’
else
grade = ‘F’;
conditional statement:
total > 60 ? grade = ‘P’: grade = ‘F’;
OR
grade = total > 60 ? ‘P’: ‘F’;
Example 2:
if/else statement:
if (total > 60)
printf(“Passed!!n”);
else
printf(“Failed!!n”);
Conditional Statement:
printf(“%s!!n”, total > 60? “Passed”:“Failed”);
SPECIAL OPERATORS
o C supports some special operators such as comma
operator, size of operator, pointer operators (& and *)
and member selection operators( . and -> ).
The comma operator:
o The comma operator is used to link the related
expressions together or in the other way, it is used to
combine multiple statememts.
o A comma linked list of expressions are evaluated from
“left” to “right”.
i.e.
expression_1, expression_2
expression_1 is evaluated first
expression_2 is evaluated second
For Example:
value=(x=10,y=5,x+y);
-First assigns the value 10 to x, then assigns 5 to y,
and finally assigns 10(i.e. 10+5) to value.
- Since comma operator has the lowest precedence
of all operators.
-The parentheses are necessary.
x = (y=3 , y+1);     x =  4 ( ) needed
SPECIAL OPERATORS
SIZEOF OPERATOR
oThe sizeof is a compile time operator.
o When used with an operand, it returns the number of
bytes the operand occupies.
o The operand maybe a variable, a constant or a data
type qualifier.
Int a,m;
m = sizeof(a);
Printf(“size of a in bytes is %d”,m);
size of a in bytes is 2
Output:
INCREMENT AND DECREMENT
OPERATORS
o Sometimes we need to increase or drcrease a variable
by “one”.
o We can do that by using assignment operator =. For
example the statement a=a+1 or a+=1 increment the
value of variable a by 1.
o In the same way the statement a=a-1 or a-=1
decrements the value of variable a by 1.
o But C language provides “Increment and Decrement
Operators” for this type of operations.
o These operators are “unary” as they take one operand
only.
o The operand can be written before of after the
operator.
o If a is a variable, then ++a is called “prefix increment”,
while a++ is called postfix increment.
o Similarly, --a is called “prefix decrement” and a– is
called “postfix decrement”.
INCREMENT AND DECREMENT
OPERATORS
Prefix ++x; or Postfix x++;
x = x + 1;
If the ++ or – operator are used in an expression or
assignment, then prefix notation and postfix notation
give different values.
a++
Post-increment. After the result is obtained, the value of
the operand is incremented by 1.
a++
Post-decrement. After the result is obtained, the value of
the operand is decremented by 1.
++a
Pre-increment. The operand is incremented by 1 and its
new value is the result of the expression.
--a
Pre-decrement. The operand is decremented by 1 and its
new value is the result of the expression.
Simple example to understand the prefix
and postfix increment:
int a=9,b;
b=a++;
printf(“%dn”,a);
printf(“%d”,b);
The output would be
10
9
But, if we execute this code…
int a=9,b;
b=++a;
printf(“%dn”,a);
printf(“%d”,b);
The output would be
10
10
Simple example to understand the prefix
and postfix decrement:
int a=9,b;
b=a--;
printf(“%dn”,a);
printf(“%d”,b);
But, if we execute this code…
int a=9,b;
b=--a;
printf(“%dn”,a);
printf(“%d”,b);
The output would be
The output would be
8
9
8
8
Complier Interpreter
Translates whole source code
into object code.
Translate land execute line
by line of source code.
User cannot see the result of
program at translation time.
User can see the result of
program at translation time.
It requires less main memory
beacuase at the time of
translation it place object
code into secondary memory.
Execution is not the job of
compiler. This is the job of
loader
It requires less main memory
beacuase at the time of
translation it place object
code into main memory and
execute it and produce the
result.
DIFFERENCES
Complier Interpreter
This process is faster than
interpreter.
This process is slower than
compiler.
Size of compiler program is
smaller than interpreter
beacuse it contain only
translation procedure.
Size of interpreter program
is larger than compiler
beacuse it contain two tasks
translation as well as loading.
DIFFERENCES
Arrays Structures
An array is a collection of
related data elements of same
type.
Structure can have elements
of different  types
Syntax: <data_type>
array_name[size];
struct struct_name
{
structure element 1;
structure element 2;
----------
----------
structure element n; }
struct_var_nm;An array is a derived data type A structure is a programmer-
defined data type
DIFFERENCES
Arrays Structures
Any array behaves like a built-
in data types. All we have to
do is to declare an array
variable and use it.
But in the case of structure,
first we have to design and
declare a data structure
before the variable of that
type are declared and used.
Array elements are accessed
by it's position or subscript.
Structure elements are
accessed by its object as '.'
operator.
Array element access takes
less time in comparison with
structures.  
Structure element access
takes more time in
comparison with arrays.
DIFFERENCES
Data Information
Data is raw, unorganized
facts that need to be
processed. Data can be
something simple and
seemingly random and useless
until it is organized.
When data is processed,
organized, structured or
presented in a given context
so as to make it useful, it is
called Information.
Each student's test score is
one piece of data
The class' average score or
the school's average score is
the information that can be
concluded from the given data.
 Data is always correct (I
can’t be 29 years old and 62
years old at the same time)
But information can be
wrong (there could be two
files on me, one saying I was
born in 1981, and one saying I
was born in 1948).
DIFFERENCES
Algorithm Flow chart
An algorithm is a finite
sequence of well defined
steps for solving a
problem in a systematic
manner.
A flow chart is a
graphical representation
of sequence of any
problem to be solved by
computer programming
language.
Difficult to show
branching and looping.
Easy for branching and
looping.
 It does not includes any
specific symbols.
Flowchart uses specific
symbols for specific
reasons.
DIFFERENCES
Start
Read a,b
Sum=a+b
Print”sum=
“,sum
Stop
Step1: input two numbers:a,b
Step2: sum=a+b
Step3: print”sum= “,sum
Step 4: Stop
Flow Chart:
Algorithm:
System Software Application
Software
System software is computer
software designed to operate
the computer hardware and to
provide a platform for running
application software.
Application software is
computer software designed
to help the user to perform
specific tasks.
It is general-purpose
software.
It is specific purpose
software.
System Software Create his
own environment to run itself
and run other application.
Application Software
performs in a environment
which created by
System/Operating System
It executes all the time in
computer.
It executes as and when
required.
DIFFERENCES
System Software Application Software
System software is essential
for a computer
System software is essential for
a computer
The number of system
software is less than
application software.
The number of application
software is much more than
system software.
System software is written in
low level language
Application software are usually
written in high level language
Detail knowledge of hardware
is required.
Detail knowledge of
organization is required.
DIFFERENCES
Call by value Call by reference
call by value passes the copy of
the variable to the function
that process it 
call by reference passes the
memory reference of the
variable (pointer) to the
function.
main ()
{
sum (10, 20);
//other code...
}
function sum (a, b)
{ //your code.....
}
main ()
{
sum (&a, &b);
//other code...
}
function sum (*a, *b)
{ //your code.....
}
 call by value increases the
memory assigned to the code
because of the copy of variables
at each reference 
whereas call by reference
utilizes the same reference of
variable at each reference.
Types of c operators ppt

More Related Content

PPT
Pointers C programming
PPTX
Input and Output In C Language
PPTX
Functions in c++
PPTX
Loops c++
PPTX
Function in C Programming
PPTX
Operators and expressions
PPTX
Function overloading and overriding
PPTX
Pointers C programming
Input and Output In C Language
Functions in c++
Loops c++
Function in C Programming
Operators and expressions
Function overloading and overriding

What's hot (20)

PPTX
Type conversion, precedence, associativity in c programming
PDF
Operators in c programming
PPTX
Functions in C
PPTX
If statements in c programming
PPTX
C Programming: Control Structure
PPTX
If else statement in c++
PPTX
PPT
User defined functions in C programmig
PDF
Python programming : Control statements
PPTX
Type Conversion, Precedence and Associativity
PPT
Operators in C++
PPTX
Keywords in c language
PPT
operator
PPTX
Decision statements in c language
PPTX
PDF
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Introduction to c++
PPTX
Functions in C
PPTX
C Token’s
PPTX
Function C programming
Type conversion, precedence, associativity in c programming
Operators in c programming
Functions in C
If statements in c programming
C Programming: Control Structure
If else statement in c++
User defined functions in C programmig
Python programming : Control statements
Type Conversion, Precedence and Associativity
Operators in C++
Keywords in c language
operator
Decision statements in c language
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
Introduction to c++
Functions in C
C Token’s
Function C programming
Ad

Similar to Types of c operators ppt (20)

PPT
C operators
PPT
C program
PDF
Unit 1
PPTX
component of c language.pptx
PPTX
C Programming Introduction
PPTX
What is c
DOC
C fundamental
PPTX
comp 122 Chapter 2.pptx,language semantics
PPTX
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
PPTX
Introduction to Java
DOCX
Programming Fundamentals lecture 7
PDF
[C++][a] tutorial 2
PDF
java or oops class not in kerala polytechnic 4rth semester nots j
PPTX
C++.pptx
DOCX
PYTHON NOTES
 
PPTX
Programming in C
PDF
Fundamentals of c language
PPTX
programing in c PPT Gaurav Nautiyal.pptx
DOCX
Basics of c++
PPTX
C and C++ programming basics for Beginners.pptx
C operators
C program
Unit 1
component of c language.pptx
C Programming Introduction
What is c
C fundamental
comp 122 Chapter 2.pptx,language semantics
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
Introduction to Java
Programming Fundamentals lecture 7
[C++][a] tutorial 2
java or oops class not in kerala polytechnic 4rth semester nots j
C++.pptx
PYTHON NOTES
 
Programming in C
Fundamentals of c language
programing in c PPT Gaurav Nautiyal.pptx
Basics of c++
C and C++ programming basics for Beginners.pptx
Ad

Recently uploaded (20)

PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Understanding Forklifts - TECH EHS Solution
PDF
System and Network Administraation Chapter 3
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Cost to Outsource Software Development in 2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
assetexplorer- product-overview - presentation
Why Generative AI is the Future of Content, Code & Creativity?
Understanding Forklifts - TECH EHS Solution
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Reimagine Home Health with the Power of Agentic AI​
Odoo Companies in India – Driving Business Transformation.pdf
Digital Systems & Binary Numbers (comprehensive )
Cost to Outsource Software Development in 2025
Operating system designcfffgfgggggggvggggggggg
Navsoft: AI-Powered Business Solutions & Custom Software Development
Design an Analysis of Algorithms II-SECS-1021-03
Design an Analysis of Algorithms I-SECS-1021-03
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PTS Company Brochure 2025 (1).pdf.......
assetexplorer- product-overview - presentation

Types of c operators ppt

  • 2. C Operators and Some Differences Contents Operator: •Arithmetic Operators •Increment & Decrement Operators •Special Operators •Conditional Operators Difference: •Data and Information •Compiler and Interpreter •System software and Application Software •Algorithm and Flowchart •Array and Structure •Call by Value and Call by Reference
  • 3.  Operators are symbols which take one or more operands or expressions and perform arithmetic or logical computations.   Operands are variables or expressions which are used in conjunction with operators to evaluate the expression.  Combination of operands and operators form an expression.  OPERATORS
  • 4. Expressions Combination of Operators and Operands Example 2 * y + 5 Operands Operators
  • 6. Arithmetic Operators o As the name is given, arithmetic operators perform arithmetic operations. o C language provides following arithmetic operators. Operator name  Meaning + Addition - Subtraction * Multiplication / Division % Modulus(Reminder after division)
  • 7. ARITHMETIC OPERATORS o These are “Binary Operators” as they take two operands. o The operands must be ”Numeric Value”. o When both the operands are integer , then the result is integer. But when one of them is floating point and other is integer then the result is floating point. oExcept “% ” operators, all the arithmetic operators can be used with any type of numeric operands(either operands are integer or floating point), while “%” operator can only be used with integer data type only.
  • 9. Output of the following code will be like this: summation of a and b=6.000000 subtraction of a and b=2.000000 multiplication of a and b=8.000000 division of a and b=2.000000
  • 10. CONDITIONAL OPERATORS o C language provides “?” operator as a conditional operator. o These are “Ternary Operators” as they take three operands. oIt is used as shown below: Syntax: Condition ? Expression1 : Expression2 -The statement above is equivalent to: if (Condition) Expression1 else Expression2
  • 11. o The operator “?” works as follows: o Expression1 is evaluated first. If it is nonzero(true), then the expression2 is evaluated and becomes the value of the expression. o If expression1 is false, expression3 is evaluated and its value becomes the value of the expression. o It is to be noted that only one of the expression(either expression2 or expression3) is evaluated. o Hence, there is no dought that ternary operators are the alternative use of “if..else” statement. CONDITIONAL OPERATORS
  • 12. Example 1: if/else statement: if (total > 60) grade = ‘P’ else grade = ‘F’; conditional statement: total > 60 ? grade = ‘P’: grade = ‘F’; OR grade = total > 60 ? ‘P’: ‘F’;
  • 13. Example 2: if/else statement: if (total > 60) printf(“Passed!!n”); else printf(“Failed!!n”); Conditional Statement: printf(“%s!!n”, total > 60? “Passed”:“Failed”);
  • 14. SPECIAL OPERATORS o C supports some special operators such as comma operator, size of operator, pointer operators (& and *) and member selection operators( . and -> ). The comma operator: o The comma operator is used to link the related expressions together or in the other way, it is used to combine multiple statememts. o A comma linked list of expressions are evaluated from “left” to “right”.
  • 15. i.e. expression_1, expression_2 expression_1 is evaluated first expression_2 is evaluated second For Example: value=(x=10,y=5,x+y); -First assigns the value 10 to x, then assigns 5 to y, and finally assigns 10(i.e. 10+5) to value. - Since comma operator has the lowest precedence of all operators. -The parentheses are necessary. x = (y=3 , y+1);     x =  4 ( ) needed SPECIAL OPERATORS
  • 16. SIZEOF OPERATOR oThe sizeof is a compile time operator. o When used with an operand, it returns the number of bytes the operand occupies. o The operand maybe a variable, a constant or a data type qualifier. Int a,m; m = sizeof(a); Printf(“size of a in bytes is %d”,m); size of a in bytes is 2 Output:
  • 17. INCREMENT AND DECREMENT OPERATORS o Sometimes we need to increase or drcrease a variable by “one”. o We can do that by using assignment operator =. For example the statement a=a+1 or a+=1 increment the value of variable a by 1. o In the same way the statement a=a-1 or a-=1 decrements the value of variable a by 1. o But C language provides “Increment and Decrement Operators” for this type of operations.
  • 18. o These operators are “unary” as they take one operand only. o The operand can be written before of after the operator. o If a is a variable, then ++a is called “prefix increment”, while a++ is called postfix increment. o Similarly, --a is called “prefix decrement” and a– is called “postfix decrement”. INCREMENT AND DECREMENT OPERATORS Prefix ++x; or Postfix x++; x = x + 1;
  • 19. If the ++ or – operator are used in an expression or assignment, then prefix notation and postfix notation give different values. a++ Post-increment. After the result is obtained, the value of the operand is incremented by 1. a++ Post-decrement. After the result is obtained, the value of the operand is decremented by 1. ++a Pre-increment. The operand is incremented by 1 and its new value is the result of the expression. --a Pre-decrement. The operand is decremented by 1 and its new value is the result of the expression.
  • 20. Simple example to understand the prefix and postfix increment: int a=9,b; b=a++; printf(“%dn”,a); printf(“%d”,b); The output would be 10 9 But, if we execute this code… int a=9,b; b=++a; printf(“%dn”,a); printf(“%d”,b); The output would be 10 10
  • 21. Simple example to understand the prefix and postfix decrement: int a=9,b; b=a--; printf(“%dn”,a); printf(“%d”,b); But, if we execute this code… int a=9,b; b=--a; printf(“%dn”,a); printf(“%d”,b); The output would be The output would be 8 9 8 8
  • 22. Complier Interpreter Translates whole source code into object code. Translate land execute line by line of source code. User cannot see the result of program at translation time. User can see the result of program at translation time. It requires less main memory beacuase at the time of translation it place object code into secondary memory. Execution is not the job of compiler. This is the job of loader It requires less main memory beacuase at the time of translation it place object code into main memory and execute it and produce the result. DIFFERENCES
  • 23. Complier Interpreter This process is faster than interpreter. This process is slower than compiler. Size of compiler program is smaller than interpreter beacuse it contain only translation procedure. Size of interpreter program is larger than compiler beacuse it contain two tasks translation as well as loading. DIFFERENCES
  • 24. Arrays Structures An array is a collection of related data elements of same type. Structure can have elements of different  types Syntax: <data_type> array_name[size]; struct struct_name { structure element 1; structure element 2; ---------- ---------- structure element n; } struct_var_nm;An array is a derived data type A structure is a programmer- defined data type DIFFERENCES
  • 25. Arrays Structures Any array behaves like a built- in data types. All we have to do is to declare an array variable and use it. But in the case of structure, first we have to design and declare a data structure before the variable of that type are declared and used. Array elements are accessed by it's position or subscript. Structure elements are accessed by its object as '.' operator. Array element access takes less time in comparison with structures.   Structure element access takes more time in comparison with arrays. DIFFERENCES
  • 26. Data Information Data is raw, unorganized facts that need to be processed. Data can be something simple and seemingly random and useless until it is organized. When data is processed, organized, structured or presented in a given context so as to make it useful, it is called Information. Each student's test score is one piece of data The class' average score or the school's average score is the information that can be concluded from the given data.  Data is always correct (I can’t be 29 years old and 62 years old at the same time) But information can be wrong (there could be two files on me, one saying I was born in 1981, and one saying I was born in 1948). DIFFERENCES
  • 27. Algorithm Flow chart An algorithm is a finite sequence of well defined steps for solving a problem in a systematic manner. A flow chart is a graphical representation of sequence of any problem to be solved by computer programming language. Difficult to show branching and looping. Easy for branching and looping.  It does not includes any specific symbols. Flowchart uses specific symbols for specific reasons. DIFFERENCES
  • 28. Start Read a,b Sum=a+b Print”sum= “,sum Stop Step1: input two numbers:a,b Step2: sum=a+b Step3: print”sum= “,sum Step 4: Stop Flow Chart: Algorithm:
  • 29. System Software Application Software System software is computer software designed to operate the computer hardware and to provide a platform for running application software. Application software is computer software designed to help the user to perform specific tasks. It is general-purpose software. It is specific purpose software. System Software Create his own environment to run itself and run other application. Application Software performs in a environment which created by System/Operating System It executes all the time in computer. It executes as and when required. DIFFERENCES
  • 30. System Software Application Software System software is essential for a computer System software is essential for a computer The number of system software is less than application software. The number of application software is much more than system software. System software is written in low level language Application software are usually written in high level language Detail knowledge of hardware is required. Detail knowledge of organization is required. DIFFERENCES
  • 31. Call by value Call by reference call by value passes the copy of the variable to the function that process it  call by reference passes the memory reference of the variable (pointer) to the function. main () { sum (10, 20); //other code... } function sum (a, b) { //your code..... } main () { sum (&a, &b); //other code... } function sum (*a, *b) { //your code..... }  call by value increases the memory assigned to the code because of the copy of variables at each reference  whereas call by reference utilizes the same reference of variable at each reference.