SlideShare a Scribd company logo
OPERATORS & EXPRESSIONS
Session 3
OBJECTIVES
• Explain Assignment Operators
• Understand Arithmetic Expressions
• Explain Relational and Logical Operators
• Understand Bitwise Logical Operators and Expressions
• Explain Casts
• Understand the Precedence of Operators
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
2
OPERATORS
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
3
• C has a very rich set of operators.
• Operators are the tools that manipulate data.
• An operator is a symbol, which represents some particular operation to be
performed on the data.
• C defines four classes of operators: arithmetic, relational, logical, and bitwise.
• In addition C has some special operators for special tasks.
• Operators operate on constants or variables, which are called operands.
• binary operators act on two data elements and ternary operators operate on three
data elements.
• For Ex: c = a + b;
Here a, b, c are the operands and ‘=’ and ‘+’ are the operators.
EXPRESSIONS
• An expression can be any combination of operators and operands.
• Operators perform operations like addition, subtraction, comparison etc.
• Operands are the variables or values on which the operations are performed. For
example, in a + b, a and b are operands and + is the operator.
• The whole thing together is an expression.
• The following are examples of expressions:
• 2
• X
• 3 + 7
• 2 × y + 5
• 2 + 6 × (4 - 2) z + 3 × (8 - z)
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
4
ASSIGNMENT OPERATOR
• Before looking into other operators, it is essential to discuss the assignment
operator (=).
• It is the most common operator in any language, and well known to everyone.
• In C, the assignment operator can be used with any valid C expression.
• The general form of the assignment operator is:
• Variablename=expression
• Int num=13;
• Float tempreture=23.222;
• String name =“ali”;
• Many variables can be assigned the same value in a single statement.
• a = b = c =10; // Multiple Assignments
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
5
Operators Example/Description
=
sum = 10;
10 is assigned to variable sum
+=
sum += 10;
This is same as sum = sum + 10
-=
sum -= 10;
This is same as sum = sum – 10
*=
sum *= 10;
This is same as sum = sum * 10
/=
sum /= 10;
This is same as sum = sum / 10
%=
sum %= 10;
This is same as sum = sum % 10
&=
sum&=10;
This is same as sum = sum & 10
^=
sum ^= 10;
This is same as sum = sum ^ 10
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
6
CODE
1
2
3
4
5
6
7
8
9
10
11
# include <stdio.h>
int main()
{
int Total=0,i;
for(i=0;i<10;i++)
{
Total+=i; // This is same as Total = Toatal+i
}
printf("Total = %d", Total);
}
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
7
ARITHMETIC OPERATOR IN C
• The operations are carried out in a specific (or a particular) order, to arrive at the
final value. This order is known as order of precedence (discussed later).
• Mathematical expressions can be expressed in C using the arithmetic operators with
numeric and character operands.
• Such expressions are known as Arithmetic Expressions.
• a * (b+c/d)/22;
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
8
Arithmetic Operators/Operation Example
+ (Addition) A+B
– (Subtraction) A-B
* (multiplication) A*B
/ (Division) A/B
% (Modulus) A%B
CODE
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int main()
{
int a=40,b=20, add,sub,mul,div,mod;
add = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("Addition of a, b is : %dn", add);
printf("Subtraction of a, b is : %dn", sub);
printf("Multiplication of a, b is : %dn", mul);
printf("Division of a, b is : %dn", div);
printf("Modulus of a, b is : %dn", mod);
}
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
9
RELATIONAL OPERATOR
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
10
• Relational operators are used to find the relation between two variables. i.e. to
compare the values of two variables in a C program.
Operators Example/Description
> x > y (x is greater than y)
< x < y (x is less than y)
>= x >= y (x is greater than or equal to y)
<= x <= y (x is less than or equal to y)
== x == y (x is equal to y)
!= x != y (x is not equal to y)
CODE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
int main()
{
int m=40,n=20;
if (m == n)
{
printf("m and n are equal");
}
else
{
printf("m and n are not equal");
}
}
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
11
LOGICAL OPERATOR
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
12
• These operators are used to perform logical operations on the given expressions.
• There are 3 logical operators in C language. They are, logical AND (&&), logical
OR (||) and logical NOT (!).
Operators Example/Description
&& (logical AND)
(x>5)&&(y<5)
It returns true when both conditions are true
|| (logical OR)
(x>=10)||(y>=10)
It returns true when at-least one of the condition is true
! (logical NOT)
!((x>5)&&(y<5))
It reverses the state of the operand “((x>5) && (y<5))”
If “((x>5) && (y<5))” is true, logical NOT operator makes it false
EXAMPLE
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
13
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
int main()
{
int m=40,n=20;
int o=20,p=30;
if (m>n && m !=0)
{
printf("&& Operator : Both conditions are truen");
}
if (o>p || p!=20)
{
printf("|| Operator : Only one condition is truen");
}
if (!(m>n && m !=0))
{
printf("! Operator : Both conditions are truen");
}
else
{
printf("! Operator : Both conditions are true. " 
"But, status is inverted as falsen");
}
}
BITWISE OPERATOR
• These operators are used to perform bit operations. Decimal values are converted
into binary values which are the sequence of bits and bit wise operators work on
these bits.
• Bit wise operators in C language are & (bitwise AND), | (bitwise OR), ~ (bitwise NOT),
^ (XOR), << (left shift) and >> (right shift).
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
14
CODE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int main()
{
int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ;
AND_opr = (m&n);
OR_opr = (m|n);
NOT_opr = (~m);
XOR_opr = (m^n);
printf("AND_opr value = %dn",AND_opr );
printf("OR_opr value = %dn",OR_opr );
printf("NOT_opr value = %dn",NOT_opr );
printf("XOR_opr value = %dn",XOR_opr );
printf("left_shift value = %dn", m << 1);
printf("right_shift value = %dn", m >> 1);
}Presented by: Muhammad Ehtisham Siddiqui (BSCS)
15
OUTPUT:
AND_opr value = 0
OR_opr value = 120
NOT_opr value = -41
XOR_opr value = 120
left_shift value = 80
right_shift value = 20
Presented by: Muhammad Ehtisham Siddiqui (BSCS)
16

More Related Content

What's hot

Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
S.M. Salaquzzaman
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
Hassaan Rahman
 
Theory3
Theory3Theory3
Operators in Python
Operators in PythonOperators in Python
Operators in Python
Anusuya123
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
guest58c84c
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
Anuja Lad
 
Python Operators
Python OperatorsPython Operators
Python Operators
Adheetha O. V
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
Abhilash Nair
 
c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
AAKASH KUMAR
 
Operators
OperatorsOperators
Operators
Kamran
 
C programming Tutorial Session 4
C programming Tutorial Session 4C programming Tutorial Session 4
C programming Tutorial Session 4
Muhammad Ehtisham Siddiqui
 
Operators and Expression
Operators and ExpressionOperators and Expression
Operators and Expression
shubham_jangid
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
alish sha
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
Garrett Gutierrez
 
C Programming Introduction
C Programming IntroductionC Programming Introduction
C Programming Introduction
Honey Sharma
 
Bisection Method
Bisection Method Bisection Method
Bisection Method
Pritam Shil
 

What's hot (19)

Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
Theory3
Theory3Theory3
Theory3
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Python Operators
Python OperatorsPython Operators
Python Operators
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
 
c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
 
Operators
OperatorsOperators
Operators
 
C programming Tutorial Session 4
C programming Tutorial Session 4C programming Tutorial Session 4
C programming Tutorial Session 4
 
Operators and Expression
Operators and ExpressionOperators and Expression
Operators and Expression
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
 
C Programming Introduction
C Programming IntroductionC Programming Introduction
C Programming Introduction
 
Bisection Method
Bisection Method Bisection Method
Bisection Method
 

Similar to C programming Tutorial Session 4

Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
Kaushal Patel
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
ruchisuru20001
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
savitamhaske
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
rinkugupta37
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
Nithya K
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
VAIBHAV175947
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
sotlsoc
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
MaryJacob24
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
rohassanie
 
Operators
OperatorsOperators
3306617
33066173306617
3306617
shwetakks
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
Saranya saran
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
Fiaz Khokhar
 
C fundamental
C fundamentalC fundamental
C fundamental
Selvam Edwin
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
Sachin Sharma
 
Operators
OperatorsOperators
Operators
VijayaLakshmi506
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdf
RichardMathengeSPASP
 

Similar to C programming Tutorial Session 4 (20)

Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
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
 
PROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptxPROGRAMMING IN C - Operators.pptx
PROGRAMMING IN C - Operators.pptx
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
C Operators and Control Structures.pdf
C Operators and Control Structures.pdfC Operators and Control Structures.pdf
C Operators and Control Structures.pdf
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Operators
OperatorsOperators
Operators
 
3306617
33066173306617
3306617
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Operators
OperatorsOperators
Operators
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdf
 

More from Muhammad Ehtisham Siddiqui

C programming Tutorial Session 3
C programming Tutorial Session 3C programming Tutorial Session 3
C programming Tutorial Session 3
Muhammad Ehtisham Siddiqui
 
C programming Tutorial Session 2
C programming Tutorial Session 2C programming Tutorial Session 2
C programming Tutorial Session 2
Muhammad Ehtisham Siddiqui
 
C programming Tutorial Session 1
C programming Tutorial Session 1C programming Tutorial Session 1
C programming Tutorial Session 1
Muhammad Ehtisham Siddiqui
 
HTML5 Web storage
HTML5 Web storageHTML5 Web storage
HTML5 Web storage
Muhammad Ehtisham Siddiqui
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
JavaScript Session 2
JavaScript Session 2JavaScript Session 2
JavaScript Session 2
Muhammad Ehtisham Siddiqui
 
JavaScript Session 3
JavaScript Session 3JavaScript Session 3
JavaScript Session 3
Muhammad Ehtisham Siddiqui
 
Javascript session 1
Javascript session 1Javascript session 1
Javascript session 1
Muhammad Ehtisham Siddiqui
 
Html audio video
Html audio videoHtml audio video
Html audio video
Muhammad Ehtisham Siddiqui
 
Html 5 geolocation api
Html 5 geolocation api Html 5 geolocation api
Html 5 geolocation api
Muhammad Ehtisham Siddiqui
 
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham SiddiquiBuiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session6
Building Next Generation Websites Session6Building Next Generation Websites Session6
Building Next Generation Websites Session6
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session5
Building Next Generation Websites Session5Building Next Generation Websites Session5
Building Next Generation Websites Session5
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session4
Building Next Generation Websites Session4Building Next Generation Websites Session4
Building Next Generation Websites Session4
Muhammad Ehtisham Siddiqui
 
Session4
Session4Session4
Office session14
Office session14Office session14
Office session14
Muhammad Ehtisham Siddiqui
 
Office session13
Office session13Office session13
Office session13
Muhammad Ehtisham Siddiqui
 

More from Muhammad Ehtisham Siddiqui (20)

C programming Tutorial Session 3
C programming Tutorial Session 3C programming Tutorial Session 3
C programming Tutorial Session 3
 
C programming Tutorial Session 2
C programming Tutorial Session 2C programming Tutorial Session 2
C programming Tutorial Session 2
 
C programming Tutorial Session 1
C programming Tutorial Session 1C programming Tutorial Session 1
C programming Tutorial Session 1
 
HTML5 Web storage
HTML5 Web storageHTML5 Web storage
HTML5 Web storage
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
 
JavaScript Session 2
JavaScript Session 2JavaScript Session 2
JavaScript Session 2
 
JavaScript Session 3
JavaScript Session 3JavaScript Session 3
JavaScript Session 3
 
Javascript session 1
Javascript session 1Javascript session 1
Javascript session 1
 
Html audio video
Html audio videoHtml audio video
Html audio video
 
Html 5 geolocation api
Html 5 geolocation api Html 5 geolocation api
Html 5 geolocation api
 
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham SiddiquiBuiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session6
Building Next Generation Websites Session6Building Next Generation Websites Session6
Building Next Generation Websites Session6
 
Building Next Generation Websites Session5
Building Next Generation Websites Session5Building Next Generation Websites Session5
Building Next Generation Websites Session5
 
Building Next Generation Websites Session4
Building Next Generation Websites Session4Building Next Generation Websites Session4
Building Next Generation Websites Session4
 
Session4
Session4Session4
Session4
 
Office session14
Office session14Office session14
Office session14
 
Office session13
Office session13Office session13
Office session13
 

Recently uploaded

Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 

Recently uploaded (20)

Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 

C programming Tutorial Session 4

  • 2. OBJECTIVES • Explain Assignment Operators • Understand Arithmetic Expressions • Explain Relational and Logical Operators • Understand Bitwise Logical Operators and Expressions • Explain Casts • Understand the Precedence of Operators Presented by: Muhammad Ehtisham Siddiqui (BSCS) 2
  • 3. OPERATORS Presented by: Muhammad Ehtisham Siddiqui (BSCS) 3 • C has a very rich set of operators. • Operators are the tools that manipulate data. • An operator is a symbol, which represents some particular operation to be performed on the data. • C defines four classes of operators: arithmetic, relational, logical, and bitwise. • In addition C has some special operators for special tasks. • Operators operate on constants or variables, which are called operands. • binary operators act on two data elements and ternary operators operate on three data elements. • For Ex: c = a + b; Here a, b, c are the operands and ‘=’ and ‘+’ are the operators.
  • 4. EXPRESSIONS • An expression can be any combination of operators and operands. • Operators perform operations like addition, subtraction, comparison etc. • Operands are the variables or values on which the operations are performed. For example, in a + b, a and b are operands and + is the operator. • The whole thing together is an expression. • The following are examples of expressions: • 2 • X • 3 + 7 • 2 × y + 5 • 2 + 6 × (4 - 2) z + 3 × (8 - z) Presented by: Muhammad Ehtisham Siddiqui (BSCS) 4
  • 5. ASSIGNMENT OPERATOR • Before looking into other operators, it is essential to discuss the assignment operator (=). • It is the most common operator in any language, and well known to everyone. • In C, the assignment operator can be used with any valid C expression. • The general form of the assignment operator is: • Variablename=expression • Int num=13; • Float tempreture=23.222; • String name =“ali”; • Many variables can be assigned the same value in a single statement. • a = b = c =10; // Multiple Assignments Presented by: Muhammad Ehtisham Siddiqui (BSCS) 5
  • 6. Operators Example/Description = sum = 10; 10 is assigned to variable sum += sum += 10; This is same as sum = sum + 10 -= sum -= 10; This is same as sum = sum – 10 *= sum *= 10; This is same as sum = sum * 10 /= sum /= 10; This is same as sum = sum / 10 %= sum %= 10; This is same as sum = sum % 10 &= sum&=10; This is same as sum = sum & 10 ^= sum ^= 10; This is same as sum = sum ^ 10 Presented by: Muhammad Ehtisham Siddiqui (BSCS) 6
  • 7. CODE 1 2 3 4 5 6 7 8 9 10 11 # include <stdio.h> int main() { int Total=0,i; for(i=0;i<10;i++) { Total+=i; // This is same as Total = Toatal+i } printf("Total = %d", Total); } Presented by: Muhammad Ehtisham Siddiqui (BSCS) 7
  • 8. ARITHMETIC OPERATOR IN C • The operations are carried out in a specific (or a particular) order, to arrive at the final value. This order is known as order of precedence (discussed later). • Mathematical expressions can be expressed in C using the arithmetic operators with numeric and character operands. • Such expressions are known as Arithmetic Expressions. • a * (b+c/d)/22; Presented by: Muhammad Ehtisham Siddiqui (BSCS) 8 Arithmetic Operators/Operation Example + (Addition) A+B – (Subtraction) A-B * (multiplication) A*B / (Division) A/B % (Modulus) A%B
  • 9. CODE 7 8 9 10 11 12 13 14 15 16 #include <stdio.h> int main() { int a=40,b=20, add,sub,mul,div,mod; add = a+b; sub = a-b; mul = a*b; div = a/b; mod = a%b; printf("Addition of a, b is : %dn", add); printf("Subtraction of a, b is : %dn", sub); printf("Multiplication of a, b is : %dn", mul); printf("Division of a, b is : %dn", div); printf("Modulus of a, b is : %dn", mod); } Presented by: Muhammad Ehtisham Siddiqui (BSCS) 9
  • 10. RELATIONAL OPERATOR Presented by: Muhammad Ehtisham Siddiqui (BSCS) 10 • Relational operators are used to find the relation between two variables. i.e. to compare the values of two variables in a C program. Operators Example/Description > x > y (x is greater than y) < x < y (x is less than y) >= x >= y (x is greater than or equal to y) <= x <= y (x is less than or equal to y) == x == y (x is equal to y) != x != y (x is not equal to y)
  • 11. CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> int main() { int m=40,n=20; if (m == n) { printf("m and n are equal"); } else { printf("m and n are not equal"); } } Presented by: Muhammad Ehtisham Siddiqui (BSCS) 11
  • 12. LOGICAL OPERATOR Presented by: Muhammad Ehtisham Siddiqui (BSCS) 12 • These operators are used to perform logical operations on the given expressions. • There are 3 logical operators in C language. They are, logical AND (&&), logical OR (||) and logical NOT (!). Operators Example/Description && (logical AND) (x>5)&&(y<5) It returns true when both conditions are true || (logical OR) (x>=10)||(y>=10) It returns true when at-least one of the condition is true ! (logical NOT) !((x>5)&&(y<5)) It reverses the state of the operand “((x>5) && (y<5))” If “((x>5) && (y<5))” is true, logical NOT operator makes it false
  • 13. EXAMPLE Presented by: Muhammad Ehtisham Siddiqui (BSCS) 13 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include <stdio.h> int main() { int m=40,n=20; int o=20,p=30; if (m>n && m !=0) { printf("&& Operator : Both conditions are truen"); } if (o>p || p!=20) { printf("|| Operator : Only one condition is truen"); } if (!(m>n && m !=0)) { printf("! Operator : Both conditions are truen"); } else { printf("! Operator : Both conditions are true. " "But, status is inverted as falsen"); } }
  • 14. BITWISE OPERATOR • These operators are used to perform bit operations. Decimal values are converted into binary values which are the sequence of bits and bit wise operators work on these bits. • Bit wise operators in C language are & (bitwise AND), | (bitwise OR), ~ (bitwise NOT), ^ (XOR), << (left shift) and >> (right shift). Presented by: Muhammad Ehtisham Siddiqui (BSCS) 14
  • 15. CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <stdio.h> int main() { int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ; AND_opr = (m&n); OR_opr = (m|n); NOT_opr = (~m); XOR_opr = (m^n); printf("AND_opr value = %dn",AND_opr ); printf("OR_opr value = %dn",OR_opr ); printf("NOT_opr value = %dn",NOT_opr ); printf("XOR_opr value = %dn",XOR_opr ); printf("left_shift value = %dn", m << 1); printf("right_shift value = %dn", m >> 1); }Presented by: Muhammad Ehtisham Siddiqui (BSCS) 15 OUTPUT: AND_opr value = 0 OR_opr value = 120 NOT_opr value = -41 XOR_opr value = 120 left_shift value = 80 right_shift value = 20
  • 16. Presented by: Muhammad Ehtisham Siddiqui (BSCS) 16