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

What's hot

2. operators in c
2. operators in c2. operators in c
2. operators in camar kakde
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsDhivyaSubramaniyam
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programmingManoj Tyagi
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cSowmya Jyothi
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in CJeya Lakshmi
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programmingprogramming9
 
Operator overloading in C++
Operator  overloading in C++Operator  overloading in C++
Operator overloading in C++BalajiGovindan5
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Types of Programming Errors
Types of Programming ErrorsTypes of Programming Errors
Types of Programming ErrorsNeha Sharma
 

What's hot (20)

2. operators in c
2. operators in c2. operators in c
2. operators in c
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Operator overloading in C++
Operator  overloading in C++Operator  overloading in C++
Operator overloading in C++
 
Relational operators
Relational operatorsRelational operators
Relational operators
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Types of Programming Errors
Types of Programming ErrorsTypes of Programming Errors
Types of Programming Errors
 

Similar to Types of c operators ppt

C operators
C operatorsC operators
C operatorsGPERI
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptxAnisZahirahAzman
 
C Programming Introduction
C Programming IntroductionC Programming Introduction
C Programming IntroductionHoney Sharma
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2yasir_cesc
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTESNi
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c languageAkshhayPatel
 
programing in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptxprograming in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptxHacker301428
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 

Similar to Types of c operators ppt (20)

C operators
C operatorsC operators
C operators
 
C program
C programC program
C program
 
Unit 1
Unit 1Unit 1
Unit 1
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
C Programming Introduction
C Programming IntroductionC Programming Introduction
C Programming Introduction
 
What is c
What is cWhat is c
What is c
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTES
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Fundamentals of c language
Fundamentals of c languageFundamentals of c language
Fundamentals of c language
 
programing in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptxprograming in c PPT Gaurav Nautiyal.pptx
programing in c PPT Gaurav Nautiyal.pptx
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
C basics
C basicsC basics
C basics
 
C basics
C basicsC basics
C basics
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 

Recently uploaded

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 

Recently uploaded (20)

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 

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.