SlideShare a Scribd company logo
1 of 14
Definition
• A bit is the smallest possible unit of data
storage and has only two values: 0 and 1
• Types:
1. The one’s complement
2. The logical bitwise operator
3. The shift operators
1. The one’s complement
• The one’s complement operator is
(~) is a unary operator that reverses
the bit values i.e. 0 becomes 1 and 1
becomes 0.
• Example: 1111000
0000111
2. The logical bitwise operator
• Three logical bitwise operators are:
1. Bitwise and (&): returns 1 if both conditions
are true or 1 else returns 0
2. Bitwise or (|): returns 1 if any one condition
is 1 or true else returns 0.
3. Bitwise exclusive or(^): returns 1 if any one
condition is 1 or true.
Example
b1 b2 b1&b2 b1|b2 b1^b2
1 1 1 1 0
1 0 0 1 1
0 1 0 1 1
0 0 0 0 0
3. The shift operators
• The two shift operators are shift left (<<) and
shift right (>>) shift the bits in an integer
variable by the specified number of positions
say n.
• Syntax: x<<n
x>>n
Example: 0111 1100 shift a<<5
1100 0000
Definition
• Converting one data type to another data type
is called type conversion.
• Two ways are: automatic conversion (implicit
conversion) and type casting (explicit
conversion)
• Ex: implicit float a=5.5, b=10.;
int c=a + b;
explicit float a=5.5, b=10.4;
int c= (int)a + (int)b;
Input output operations in c
Introduction
Data is stored in file in the secondary memory.
File specification includes:
1. Filename
2. Data structure
3. Purpose
1. File pointer
• To work with files in system, a
pointer to that file is required.
• Syntax: FILE *file_pointer;
FILE *fp;
2. Opening a file
• To perform any operation, file must be
opened.
• fopen() function is used which takes file name
and mode of operation.
• Syntax: fopen(file_name, mode);
• Example: FILE *fp;
fp= fopen(“temp.dat”, ”r”);
3. Closing a file
• To close a file, fclose() function is
used along with file pointer.
• Syntax: fclose(file_pointer);
• Example: fclose(fp);
4. fprintf and fscanf functions
• They work same way like printf and scanf
functions except that these work on files.
• Syntax: fprintf(fp, “ control string”, list);
• Example:
fprintf(f1,”%s %d ”, name, age);
fscanf(f1, “%s %d”, &name, &age);

More Related Content

Similar to bit wise operators and I/O operations in C

BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12Dev Chauhan
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperationsNitesh Singh
 
Cse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionCse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionFarshidKhan
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012Shani729
 
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptxchapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptxJahnavi113937
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operationsVATSAL TRIVEDI
 
Programming techniques
Programming techniquesProgramming techniques
Programming techniquesPrabhjit Singh
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxsangeeta borde
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of CSuchit Patel
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressionsmaznabili
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming NeedsRaja Sekhar
 

Similar to bit wise operators and I/O operations in C (20)

Logic Micro Operation
Logic Micro OperationLogic Micro Operation
Logic Micro Operation
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperations
 
Cse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expressionCse lecture-4.2-c bit wise operators and expression
Cse lecture-4.2-c bit wise operators and expression
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
 
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptxchapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operations
 
Report on c
Report on cReport on c
Report on c
 
Programming techniques
Programming techniquesProgramming techniques
Programming techniques
 
3.Loops_conditionals.pdf
3.Loops_conditionals.pdf3.Loops_conditionals.pdf
3.Loops_conditionals.pdf
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptx
 
CPP17 - File IO
CPP17 - File IOCPP17 - File IO
CPP17 - File IO
 
Programing techniques
Programing techniquesPrograming techniques
Programing techniques
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
 
Unit 07 dbms
Unit 07 dbmsUnit 07 dbms
Unit 07 dbms
 
ppt_pspp.pdf
ppt_pspp.pdfppt_pspp.pdf
ppt_pspp.pdf
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 

More from preetikapri1

types of testing in software engineering
types of testing in software engineering types of testing in software engineering
types of testing in software engineering preetikapri1
 
structures in C and Union in C, enumerated datatype
structures in C and Union in C, enumerated datatypestructures in C and Union in C, enumerated datatype
structures in C and Union in C, enumerated datatypepreetikapri1
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applicationspreetikapri1
 
architecture framework for ecommerce
architecture framework for ecommercearchitecture framework for ecommerce
architecture framework for ecommercepreetikapri1
 
impact of ecommerce on traditional means
impact of ecommerce on traditional means impact of ecommerce on traditional means
impact of ecommerce on traditional means preetikapri1
 
electronic data interchange
electronic data interchange electronic data interchange
electronic data interchange preetikapri1
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applicationspreetikapri1
 

More from preetikapri1 (20)

Forces
ForcesForces
Forces
 
software quality
software qualitysoftware quality
software quality
 
UML model
UML model UML model
UML model
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
 
Data flow diagram
Data flow diagramData flow diagram
Data flow diagram
 
types of testing in software engineering
types of testing in software engineering types of testing in software engineering
types of testing in software engineering
 
structures in C and Union in C, enumerated datatype
structures in C and Union in C, enumerated datatypestructures in C and Union in C, enumerated datatype
structures in C and Union in C, enumerated datatype
 
Ms access
Ms access Ms access
Ms access
 
Functions
FunctionsFunctions
Functions
 
C programming
C programmingC programming
C programming
 
C preprocesor
C preprocesorC preprocesor
C preprocesor
 
Window object
Window objectWindow object
Window object
 
DTD elements
DTD elementsDTD elements
DTD elements
 
Html
HtmlHtml
Html
 
Css font
Css fontCss font
Css font
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
 
architecture framework for ecommerce
architecture framework for ecommercearchitecture framework for ecommerce
architecture framework for ecommerce
 
impact of ecommerce on traditional means
impact of ecommerce on traditional means impact of ecommerce on traditional means
impact of ecommerce on traditional means
 
electronic data interchange
electronic data interchange electronic data interchange
electronic data interchange
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

bit wise operators and I/O operations in C

  • 1.
  • 2. Definition • A bit is the smallest possible unit of data storage and has only two values: 0 and 1 • Types: 1. The one’s complement 2. The logical bitwise operator 3. The shift operators
  • 3. 1. The one’s complement • The one’s complement operator is (~) is a unary operator that reverses the bit values i.e. 0 becomes 1 and 1 becomes 0. • Example: 1111000 0000111
  • 4. 2. The logical bitwise operator • Three logical bitwise operators are: 1. Bitwise and (&): returns 1 if both conditions are true or 1 else returns 0 2. Bitwise or (|): returns 1 if any one condition is 1 or true else returns 0. 3. Bitwise exclusive or(^): returns 1 if any one condition is 1 or true.
  • 5. Example b1 b2 b1&b2 b1|b2 b1^b2 1 1 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 0
  • 6. 3. The shift operators • The two shift operators are shift left (<<) and shift right (>>) shift the bits in an integer variable by the specified number of positions say n. • Syntax: x<<n x>>n Example: 0111 1100 shift a<<5 1100 0000
  • 7.
  • 8. Definition • Converting one data type to another data type is called type conversion. • Two ways are: automatic conversion (implicit conversion) and type casting (explicit conversion) • Ex: implicit float a=5.5, b=10.; int c=a + b; explicit float a=5.5, b=10.4; int c= (int)a + (int)b;
  • 10. Introduction Data is stored in file in the secondary memory. File specification includes: 1. Filename 2. Data structure 3. Purpose
  • 11. 1. File pointer • To work with files in system, a pointer to that file is required. • Syntax: FILE *file_pointer; FILE *fp;
  • 12. 2. Opening a file • To perform any operation, file must be opened. • fopen() function is used which takes file name and mode of operation. • Syntax: fopen(file_name, mode); • Example: FILE *fp; fp= fopen(“temp.dat”, ”r”);
  • 13. 3. Closing a file • To close a file, fclose() function is used along with file pointer. • Syntax: fclose(file_pointer); • Example: fclose(fp);
  • 14. 4. fprintf and fscanf functions • They work same way like printf and scanf functions except that these work on files. • Syntax: fprintf(fp, “ control string”, list); • Example: fprintf(f1,”%s %d ”, name, age); fscanf(f1, “%s %d”, &name, &age);