SlideShare a Scribd company logo
1
Programming Fundamentals
Lecture 35 and 36
Dr. Aijaz Ahmed Arain
Assistant Professor
Ph.D. Information Technology
M.S. Information Technology
M.Sc. Computer Technology
B.Sc. Computer Technology
Quaid-e-Awam
University
of
Engineering,
Science
and
Technology
Department of Computer Science
Date: 06-03-2023
You can get course material
from
draijaz.quest.edu.pk
• Bitwise Operators
To be covered
2
Bitwise Operator
Bitwise operator permit programmer to access and manipulate
of data at bit level.
Various bitwise operator enlisted are
• One's complement (~)
• Bitwise AND (&)
• Bitwise OR (|)
• Bitwise XOR (^)
• Left shift (<<)
• Right shift (>>)
These operator can operate on integer and character value but
not on float and double.
Lecture 35 and 36 Bitwise Operators.pdf
Lecture 35 and 36 Bitwise Operators.pdf
Lecture 35 and 36 Bitwise Operators.pdf
Lecture 35 and 36 Bitwise Operators.pdf
Lecture 35 and 36 Bitwise Operators.pdf
Bitwise Operator
Assume if A = 60; and B = 13; now in binary format they will be
as follows:
A = 0011 1100
B = 0000 1101
-----------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
A<<2 = 1111 0000
A>>2 = 0000 1111
Bitwise Operator (Example)
main()
{
unsigned int a = 60; /* 60 = 0011 1100 */
unsigned int b = 13; /* 13 = 0000 1101 */
int c = 0;
c = a & b; printf("Line 1 - Value of c is %dn", c );
c = a | b; printf("Line 2 - Value of c is %dn", c );
c = a ^ b; printf("Line 3 - Value of c is %dn", c );
c = ~a; printf("Line 4 - Value of c is %dn", c );
c = a << 2; printf("Line 5 - Value of c is %dn", c );
c = a >> 2; printf("Line 6 - Value of c is %dn", c );
}
Bitwise Operator (Example)
Lecture 35 and 36 Bitwise Operators.pdf
Thanks

More Related Content

Similar to Lecture 35 and 36 Bitwise Operators.pdf (20)

PPTX
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
PDF
15 bitwise operators
Ravindra Rathore
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PPTX
Unit 4. Operators and Expression
Ashim Lamichhane
 
PPTX
ppt1s.pptx
ANIKULSAIKH
 
PPTX
Bit-Manipulation for competitive programming
gaurav77712
 
DOC
C bitwise operators
Suneel Dogra
 
PDF
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
ssuserd6b1fd
 
PPTX
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
PPTX
Cse lecture-4.2-c bit wise operators and expression
FarshidKhan
 
PPTX
COM1407: C Operators
Hemantha Kulathilake
 
PPTX
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
PPT
Bitwise operators
Puneet Rajput
 
PDF
Types of Operators in C
Thesis Scientist Private Limited
 
PPTX
C operators
AbiramiT9
 
PPTX
C Programming Language Part 4
Rumman Ansari
 
PPTX
Operators-computer programming and utilzation
Kaushal Patel
 
PPTX
CSE-1203-Lecture-04-Operators.pp c basictx
MARaihanEmon
 
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
15 bitwise operators
Ravindra Rathore
 
6 operators-in-c
Rohit Shrivastava
 
6 operators-in-c
Rohit Shrivastava
 
Unit 4. Operators and Expression
Ashim Lamichhane
 
ppt1s.pptx
ANIKULSAIKH
 
Bit-Manipulation for competitive programming
gaurav77712
 
C bitwise operators
Suneel Dogra
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
ssuserd6b1fd
 
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
Cse lecture-4.2-c bit wise operators and expression
FarshidKhan
 
COM1407: C Operators
Hemantha Kulathilake
 
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
Bitwise operators
Puneet Rajput
 
Types of Operators in C
Thesis Scientist Private Limited
 
C operators
AbiramiT9
 
C Programming Language Part 4
Rumman Ansari
 
Operators-computer programming and utilzation
Kaushal Patel
 
CSE-1203-Lecture-04-Operators.pp c basictx
MARaihanEmon
 

Recently uploaded (20)

PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
community health nursing question paper 2.pdf
Prince kumar
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Ad

Lecture 35 and 36 Bitwise Operators.pdf

  • 1. 1 Programming Fundamentals Lecture 35 and 36 Dr. Aijaz Ahmed Arain Assistant Professor Ph.D. Information Technology M.S. Information Technology M.Sc. Computer Technology B.Sc. Computer Technology Quaid-e-Awam University of Engineering, Science and Technology Department of Computer Science Date: 06-03-2023 You can get course material from draijaz.quest.edu.pk
  • 3. Bitwise Operator Bitwise operator permit programmer to access and manipulate of data at bit level. Various bitwise operator enlisted are • One's complement (~) • Bitwise AND (&) • Bitwise OR (|) • Bitwise XOR (^) • Left shift (<<) • Right shift (>>) These operator can operate on integer and character value but not on float and double.
  • 10. Assume if A = 60; and B = 13; now in binary format they will be as follows: A = 0011 1100 B = 0000 1101 ----------------- A&B = 0000 1100 A|B = 0011 1101 A^B = 0011 0001 ~A = 1100 0011 A<<2 = 1111 0000 A>>2 = 0000 1111 Bitwise Operator (Example)
  • 11. main() { unsigned int a = 60; /* 60 = 0011 1100 */ unsigned int b = 13; /* 13 = 0000 1101 */ int c = 0; c = a & b; printf("Line 1 - Value of c is %dn", c ); c = a | b; printf("Line 2 - Value of c is %dn", c ); c = a ^ b; printf("Line 3 - Value of c is %dn", c ); c = ~a; printf("Line 4 - Value of c is %dn", c ); c = a << 2; printf("Line 5 - Value of c is %dn", c ); c = a >> 2; printf("Line 6 - Value of c is %dn", c ); } Bitwise Operator (Example)