SlideShare a Scribd company logo
1 of 33
Download to read offline
Paper: Introduction Programming Language using C
Paper ID: 20105
Paper Code: BCA 105
DR. VARUN TIWARI
(ASSOCIATE PROFESSOR)
(DEPARTMENT OF COMPUTER SCIENCE)
BOSCO TECHNICAL TRAINING SOCIETY,
DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
C Operator
Objectives
In this unit you will learn:
1. To understand about Operator.
2. To learn about how many types of Operator.
3. To use of Bitwise Operator in C.
4. To use of Relational Operator in C.
5. To learn about Logical Operator in C.
6. To learn about Assignment Operator in C.
7. To learn about Ternary Operator in C.
8. To learn about Arithmetic Operator in C.
Operator: An operator is a symbol that is used to perform mathematical and logical
operation etc. in C language. Its tells to compiler to perform a specific calculation.
1. Arithmetic Operator
2. Relational Operator
3. Logical Operator
4. Bitwise Operator
5. Assignment Operator
6. Ternary Operator or Conditional Operator
7. Increment / Decrement Operator
8. Unary Operator and Binary Operator
1. Arithmetic Operator: It is perform arithmetic operation in C.
Example -: In this program, user input two values from keyboard and perform arithmetic
operations such as addition, subtraction, multiplication, division, modulus and output is
displayed for each operation.
Operator Description
+ For Addition
- For Subtraction
* For Multiplication
/ For Division
% For Percentage (Modulus)
2. Relational Operator: it is used to perform relation between two variables or it compare
the values of two variables in C.
Operator Description
> a>b (Compare a is greater than b) its return true/false
< a<b (Compare a is less than b) its return true/false
>= a>=b (Compare a is greater than equal to b) return true/false
<= a<=b (Compare a is less than equal to b) return true/false
== a==b (compare a is equal to b)
!= a!=b (compare a is not equal to b)
3. Logical Operator: it is used to perform logical operation on the given expression.
Operator Description
&& Logical AND
|| Logical OR
! Logical NOT
4. Bitwise Operator: it is used to perform decimal value to covert binary value which are the
form of bits and bitwise operator works in these bits. Its perform bits operation.
Truth table of Bitwise Operator:
a b a&b (AND) a|b (OR) a^b (XOR)
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
Operator Description
& Bitwise AND
| Bitwise OR
~ Bitwise NOT or Complement
^ Bitwise XOR
<< Bitwise Left Shift
>> Bitwise Right Shift
5. Assignment Operator: it is used to assign a value of variable.
Operator Description
= a=10; (assign a value of variable)
C=a+b; (passing multiple variable value to a new variable)
6. Ternary or Conditional Operator: it return one value. If the condition is true return first
otherwise it return second value. This operator is also called ternary operator.
Syn. (condition/expression? True : False)
Example: p=(i<10?11:12);
7. Increment / Decrement Operator: Increment operator increase a value of variable by
one and decrement operator is used to decrease a value of variable by one. This is two
types first is prefix and second is postfix.
Syn. ++variable name; (prefix) , variablename++ (postfix) (increment)
-- variable name (prefix) , variablename - - (postfix) (decrement)
example: ++p; (value of p increment before assigning it to the variable p) , p++ (value of
p increment after assigning it to the variable p) ;
-- p ; (value of p decrement before assigning it to the variable p) , p-- (value
of p decrement after assigning it to the variable p) ;
8. Unary Operator and Binary Operator: Unary operators that operates or works with single
operand are called unary operator. (ex: ++,--,~,size of)
Binary operator that operates or works between the two variable are called binary
operator. (+,-,/,%,*)
Hierarchy of Operations
Priority Operators Description
1st *, / , % Multiplication, division ,
modular division
2nd + , - Addition , Subtraction
3rd = Assignment
Example 1, 2, 3
 Ex- 1 - : // Perform Operation in Int Form
C = 1 * 5 / 4 + 7 / 7 + 9 – 2 + 5 / 8
C = 5/4 + 7/7 + 9 – 2 + 5/8 // operation *
C = 1 + 7/7 + 9 – 2 + 5 / 8 // Operation /
C = 1 + 1 + 9 – 2 + 5/8 // operation /
C = 1 + 1 + 9 – 2 + 0 // Operation /
C = 2 + 9 – 2 + 0 // Operation +
C = 11 – 2 + 0 // Operation +
C = 9 + 0 // Operation -
C = 9 // operation +
Example 1, 2, 3
 Ex- 2 - :
// Perform Operation in Float Form
C = 1 * 5 / 4 + 7 / 7 + 9 – 2 + 5 / 8
C = 5/4 + 7/7 + 9 – 2 + 5/8 // operation *
C = 1.25 + 7/7 + 9 – 2 + 5 / 8 // Operation /
C = 1.25 + 1.0 + 9 – 2 + 5/8 // operation /
C = 1.25 + 1.0 + 9 – 2 + 0.625 // Operation /
C = 2.25 + 9 – 2 + 0.625 // Operation +
C = 11.25 – 2 + 0.625 // Operation +
C = 9.25 + 0.625 // Operation -
C = 9.875 // operation +
Example 1, 2, 3
 Ex- 3 - :
// use modulus division
P = 4 / 6 + 12 % 4 + 8 – 9 + 2 * 7 // operation *
P = 4/6 + 12 % 4 + 8 – 9 + 14 // Operation /
P = 4 / 6 + 12%4 + 8 – 9 + 14 // Operation /
P= 0 + 12%4 + 8 -9 + 14 //Operation %
P = 0 + 0 + 8 – 9 + 14 // Operation +
P = 8 – 9 + 14 // Operation +
P = 8 – 9 + 14 // Operation -
P= -1 + 14 // Operation +
P = 13
Example 1, 2, 3
 Solve this Questions:
1. A = 12/5 + 7 – 9 %3 - 3 + 5 * 10 // int form
2. B = 4+ 6 + 9 /3 + 4*9 + 3*2 / 1 //float and int both
3. C = 5/2 + 7 * 10 – 3 % 2 + 11 + 13 /2 – 9 + 12 * 5 // int form
4. D = 7 * 8 + 12 + 6 / 2 – 8 + 10 % 2 – 5 + 9 * 1 + 2 // int form
Operator Precedence
Operator Name Description
() Parentheses (grouping)
[] Brackets (array subscript)
. Member selection via object name
-> Member selection via pointer
++ -- Unary preincrement/predecrement
+ - Unary plus/minus
! ~ Unary logical negation/bitwise complement
(type) Unary cast (change type)
* Dereference
& Address
sizeof Determine size in bytes
* / % Multiplication/division/modulus
+ - Addition/subtraction
<< >> Bitwise shift left, Bitwise shift right
< <= Relational less than/less than or equal to
> >= Relational greater than/greater than or equal to
== != Relational is equal to/is not equal to
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise inclusive OR
&& Logical AND
|| Logical OR
?: Ternary conditional
= Assignment
+= -= Addition/subtraction assignment
*= /= Multiplication/division assignment
%= &= Modulus/bitwise AND assignment
^= |= Bitwise exclusive/inclusive OR assignment
<<= >>= Bitwise shift left/right assignment
, Comma (separate expressions)
THANK YOU

More Related Content

What's hot

Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++sunny khan
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++Praveen M Jigajinni
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++zeeshan turi
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++Shobi P P
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailgourav kottawar
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Getting started in c++
Getting started in c++Getting started in c++
Getting started in c++Neeru Mittal
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATORrricky98
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 

What's hot (19)

Python : Operators
Python : OperatorsPython : Operators
Python : Operators
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
Working with IDE
Working with IDEWorking with IDE
Working with IDE
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Getting started in c++
Getting started in c++Getting started in c++
Getting started in c++
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 

Similar to C Operators

C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statementsCtOlaf
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariTHE NORTHCAP UNIVERSITY
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of PrecedenceMuhammad Hammad Waseem
 
C operators
C operatorsC operators
C operatorsGPERI
 
Operators
OperatorsOperators
OperatorsKamran
 
Topic 2_revised.pptx
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptxJAYAPRIYAR7
 
3.OPERATORS_MB.ppt .
3.OPERATORS_MB.ppt                      .3.OPERATORS_MB.ppt                      .
3.OPERATORS_MB.ppt .happycocoman
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 

Similar to C Operators (20)

C programming session 02
C programming session 02C programming session 02
C programming session 02
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Coper in C
Coper in CCoper in C
Coper in C
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
Python as a calculator
Python as a calculatorPython as a calculator
Python as a calculator
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
C operators
C operatorsC operators
C operators
 
Theory3
Theory3Theory3
Theory3
 
Operators
OperatorsOperators
Operators
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
What are operators?
What are operators? What are operators?
What are operators?
 
Topic 2_revised.pptx
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptx
 
3.OPERATORS_MB.ppt .
3.OPERATORS_MB.ppt                      .3.OPERATORS_MB.ppt                      .
3.OPERATORS_MB.ppt .
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
05 operators
05   operators05   operators
05 operators
 

More from Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)

More from Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi) (20)

String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
C Structure and Union in C
C Structure and Union in CC Structure and Union in C
C Structure and Union in C
 
Preprocessor Directive in C
Preprocessor Directive in CPreprocessor Directive in C
Preprocessor Directive in C
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
Bit field enum and command line arguments
Bit field enum and command line argumentsBit field enum and command line arguments
Bit field enum and command line arguments
 
Pointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory AllocationPointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory Allocation
 
Array in C
Array in CArray in C
Array in C
 
C storage class
C storage classC storage class
C storage class
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
 
E commerce application
E commerce applicationE commerce application
E commerce application
 
Data normalization
Data normalizationData normalization
Data normalization
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Database connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwariDatabase connectivity with data reader by varun tiwari
Database connectivity with data reader by varun tiwari
 

Recently uploaded

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Recently uploaded (20)

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

C Operators

  • 1. Paper: Introduction Programming Language using C Paper ID: 20105 Paper Code: BCA 105 DR. VARUN TIWARI (ASSOCIATE PROFESSOR) (DEPARTMENT OF COMPUTER SCIENCE) BOSCO TECHNICAL TRAINING SOCIETY, DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
  • 3. Objectives In this unit you will learn: 1. To understand about Operator. 2. To learn about how many types of Operator. 3. To use of Bitwise Operator in C. 4. To use of Relational Operator in C. 5. To learn about Logical Operator in C. 6. To learn about Assignment Operator in C. 7. To learn about Ternary Operator in C. 8. To learn about Arithmetic Operator in C.
  • 4. Operator: An operator is a symbol that is used to perform mathematical and logical operation etc. in C language. Its tells to compiler to perform a specific calculation. 1. Arithmetic Operator 2. Relational Operator 3. Logical Operator 4. Bitwise Operator 5. Assignment Operator 6. Ternary Operator or Conditional Operator 7. Increment / Decrement Operator 8. Unary Operator and Binary Operator
  • 5. 1. Arithmetic Operator: It is perform arithmetic operation in C. Example -: In this program, user input two values from keyboard and perform arithmetic operations such as addition, subtraction, multiplication, division, modulus and output is displayed for each operation. Operator Description + For Addition - For Subtraction * For Multiplication / For Division % For Percentage (Modulus)
  • 6.
  • 7.
  • 8. 2. Relational Operator: it is used to perform relation between two variables or it compare the values of two variables in C. Operator Description > a>b (Compare a is greater than b) its return true/false < a<b (Compare a is less than b) its return true/false >= a>=b (Compare a is greater than equal to b) return true/false <= a<=b (Compare a is less than equal to b) return true/false == a==b (compare a is equal to b) != a!=b (compare a is not equal to b)
  • 9.
  • 10.
  • 11. 3. Logical Operator: it is used to perform logical operation on the given expression. Operator Description && Logical AND || Logical OR ! Logical NOT
  • 12.
  • 13. 4. Bitwise Operator: it is used to perform decimal value to covert binary value which are the form of bits and bitwise operator works in these bits. Its perform bits operation. Truth table of Bitwise Operator: a b a&b (AND) a|b (OR) a^b (XOR) 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 Operator Description & Bitwise AND | Bitwise OR ~ Bitwise NOT or Complement ^ Bitwise XOR << Bitwise Left Shift >> Bitwise Right Shift
  • 14.
  • 15.
  • 16. 5. Assignment Operator: it is used to assign a value of variable. Operator Description = a=10; (assign a value of variable) C=a+b; (passing multiple variable value to a new variable)
  • 17. 6. Ternary or Conditional Operator: it return one value. If the condition is true return first otherwise it return second value. This operator is also called ternary operator. Syn. (condition/expression? True : False) Example: p=(i<10?11:12);
  • 18.
  • 19. 7. Increment / Decrement Operator: Increment operator increase a value of variable by one and decrement operator is used to decrease a value of variable by one. This is two types first is prefix and second is postfix. Syn. ++variable name; (prefix) , variablename++ (postfix) (increment) -- variable name (prefix) , variablename - - (postfix) (decrement) example: ++p; (value of p increment before assigning it to the variable p) , p++ (value of p increment after assigning it to the variable p) ; -- p ; (value of p decrement before assigning it to the variable p) , p-- (value of p decrement after assigning it to the variable p) ;
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. 8. Unary Operator and Binary Operator: Unary operators that operates or works with single operand are called unary operator. (ex: ++,--,~,size of) Binary operator that operates or works between the two variable are called binary operator. (+,-,/,%,*)
  • 27. Hierarchy of Operations Priority Operators Description 1st *, / , % Multiplication, division , modular division 2nd + , - Addition , Subtraction 3rd = Assignment
  • 28. Example 1, 2, 3  Ex- 1 - : // Perform Operation in Int Form C = 1 * 5 / 4 + 7 / 7 + 9 – 2 + 5 / 8 C = 5/4 + 7/7 + 9 – 2 + 5/8 // operation * C = 1 + 7/7 + 9 – 2 + 5 / 8 // Operation / C = 1 + 1 + 9 – 2 + 5/8 // operation / C = 1 + 1 + 9 – 2 + 0 // Operation / C = 2 + 9 – 2 + 0 // Operation + C = 11 – 2 + 0 // Operation + C = 9 + 0 // Operation - C = 9 // operation +
  • 29. Example 1, 2, 3  Ex- 2 - : // Perform Operation in Float Form C = 1 * 5 / 4 + 7 / 7 + 9 – 2 + 5 / 8 C = 5/4 + 7/7 + 9 – 2 + 5/8 // operation * C = 1.25 + 7/7 + 9 – 2 + 5 / 8 // Operation / C = 1.25 + 1.0 + 9 – 2 + 5/8 // operation / C = 1.25 + 1.0 + 9 – 2 + 0.625 // Operation / C = 2.25 + 9 – 2 + 0.625 // Operation + C = 11.25 – 2 + 0.625 // Operation + C = 9.25 + 0.625 // Operation - C = 9.875 // operation +
  • 30. Example 1, 2, 3  Ex- 3 - : // use modulus division P = 4 / 6 + 12 % 4 + 8 – 9 + 2 * 7 // operation * P = 4/6 + 12 % 4 + 8 – 9 + 14 // Operation / P = 4 / 6 + 12%4 + 8 – 9 + 14 // Operation / P= 0 + 12%4 + 8 -9 + 14 //Operation % P = 0 + 0 + 8 – 9 + 14 // Operation + P = 8 – 9 + 14 // Operation + P = 8 – 9 + 14 // Operation - P= -1 + 14 // Operation + P = 13
  • 31. Example 1, 2, 3  Solve this Questions: 1. A = 12/5 + 7 – 9 %3 - 3 + 5 * 10 // int form 2. B = 4+ 6 + 9 /3 + 4*9 + 3*2 / 1 //float and int both 3. C = 5/2 + 7 * 10 – 3 % 2 + 11 + 13 /2 – 9 + 12 * 5 // int form 4. D = 7 * 8 + 12 + 6 / 2 – 8 + 10 % 2 – 5 + 9 * 1 + 2 // int form
  • 32. Operator Precedence Operator Name Description () Parentheses (grouping) [] Brackets (array subscript) . Member selection via object name -> Member selection via pointer ++ -- Unary preincrement/predecrement + - Unary plus/minus ! ~ Unary logical negation/bitwise complement (type) Unary cast (change type) * Dereference & Address sizeof Determine size in bytes * / % Multiplication/division/modulus + - Addition/subtraction << >> Bitwise shift left, Bitwise shift right < <= Relational less than/less than or equal to > >= Relational greater than/greater than or equal to == != Relational is equal to/is not equal to & Bitwise AND ^ Bitwise exclusive OR | Bitwise inclusive OR && Logical AND || Logical OR ?: Ternary conditional = Assignment += -= Addition/subtraction assignment *= /= Multiplication/division assignment %= &= Modulus/bitwise AND assignment ^= |= Bitwise exclusive/inclusive OR assignment <<= >>= Bitwise shift left/right assignment , Comma (separate expressions)