You are previewing Programming in C, 2nd Edition.
O'Reilly logo
Programming in C, 2nd Edition

Book Description

Programming in C draws upon the exclusivity of the bestselling Programming in ANSI and Turbo C and betters it. The approach has been made less text-heavy through the inclusion of diagrams, tables and stepwise listing of key concepts. The number of programs has been greatly increased to facilitate better programming skills.

Table of Contents

  1. Cover
  2. Title Page
  3. Contents
  4. About the Author
  5. Dedication
  6. Preface
  7. 1. Basics and Introduction to ‘C’
    1. 1.1 Why to Use Computers?
    2. 1.2 Basics of a Computer
    3. 1.3 Latest Computers
    4. 1.4 Introduction to C
    5. 1.5 About ANSI C Standard
    6. 1.6 Machine, Assembly and High-Level Language
      1. 1.6.1 Assembly Language
      2. 1.6.2 High-Level Language
    7. 1.7 Assembler, Compiler and Interpreter
    8. 1.8 Structure of a C Program
    9. 1.9 Programming Rules
    10. 1.10 Executing the C Program
    11. 1.11 Standard Directories
    12. 1.12 The First C Program
    13. 1.13 Advantages of C
    14. 1.14 Header Files
    15. 1.15 Problem-Solving Techniques
    16. 1.16 Algorithm
    17. 1.17 Analysing Algorithm
    18. 1.18 Rate of Growth
      1. 1.18.1 Program Design
    19. 1.19 Classification of Algorithms
    20. Summary
    21. Exercises
  8. 2. The C Declarations
    1. 2.1 Introduction
    2. 2.2 The C Character Set
    3. 2.3 Delimiters
    4. 2.4 Types of Tokens
    5. 2.5 The C Keywords
    6. 2.6 Identifiers
    7. 2.7 Constants
      1. 2.7.1 Numerical Constants
      2. 2.7.2 Character Constant
    8. 2.8 Variables
    9. 2.9 Rules for Defining Variables
    10. 2.10 Data Types
    11. 2.11 C Data Types
    12. 2.12 Integer and Float Number Representations
      1. 2.12.1 Integer Representation
      2. 2.12.2 Floating-Point Representation
    13. 2.13 Declaring Variables
    14. 2.14 Initializing Variables
    15. 2.15 Dynamic Initialization
    16. 2.16 Type Modifiers
    17. 2.17 Type Conversion
    18. 2.18 Wrapping Around
    19. 2.19 Constant and Volatile Variables
      1. 2.19.1 Constant Variable
      2. 2.19.2 Volatile Variable
    20. Summary
    21. Exercises
  9. 3. Operators and Expressions
    1. 3.1 Introduction
    2. 3.2 Properties of Operators
    3. 3.3 Priority of Operators and Their Clubing
    4. 3.4 Comma and Conditional Operator
    5. 3.5 Arithmetic Operators
    6. 3.6 Relational Operators
    7. 3.7 Assignment Operators and Expressions
    8. 3.8 Logical Operators
    9. 3.9 Bitwise Operators
    10. Summary
    11. Exercises
  10. 4. Input and Output in C
    1. 4.1 Introduction
    2. 4.2 Formatted Functions
    3. 4.3 Unformatted Functions
    4. 4.4 Commonly Used Library Functions
    5. 4.5 Strong Points for Understandability
    6. Summary
    7. Exercises
  11. 5. Decision Statements
    1. 5.1 Introduction
    2. 5.2 The if Statement
    3. 5.3 The if–else Statement
    4. 5.4 Nested if–else Statement
    5. 5.5 if-else-if Ladder Statement
    6. 5.6 The break Statement
    7. 5.7 The continue Statement
    8. 5.8 The goto Statement
    9. 5.9 The switch Statement
    10. 5.10 Nested switch Case
    11. 5.11 The switch Case And Nested ifs
    12. Summary
    13. Exercises
  12. 6. Loop Control
    1. 6.1 Introduction
      1. 6.1.1 What is a Loop?
    2. 6.2 for Loop
    3. 6.3 Nested for Loops
    4. 6.4 while Loop
    5. 6.5 The do-while Loop
    6. 6.6 do-while Statement with while Loop
    7. 6.7 Bohm and Jacopini's Theory
    8. Summary
    9. Exercises
  13. 7. Data Structure: Array
    1. 7.1 Introduction
    2. 7.2 Array Initialization
    3. 7.3 Array Terminology
    4. 7.4 Characteristics of an Array
    5. 7.5 One-Dimensional Array
    6. 7.6 One-Dimensional Array and Operations
    7. 7.7 Operations with Arrays
    8. 7.8 Predefined Streams
    9. 7.9 Two-Dimensional Array and Operations
      1. 7.9.1 Insert Operation with Two-Dimensional Array
      2. 7.9.2 Delete Operation With Two-Dimensional Array
    10. 7.10 Three- or Multi-Dimensional Arrays
    11. 7.11 The sscanf() and sprintf() Functions
    12. 7.12 Drawbacks of Linear Arrays
    13. Summary
    14. Exercises
  14. 8. Strings and Standard Functions
    1. 8.1 Introduction
    2. 8.2 Declaration and Initialization Of String
    3. 8.3 Display of Strings With Different Formats
    4. 8.4 String Standard Functions
    5. 8.5 String Conversion Function
    6. 8.6 Memory Function
    7. 8.7 Applications of Strings
    8. Summary
    9. Exercises
  15. 9. Pointers
    1. 9.1 Introduction
    2. 9.2 Features of Pointers
    3. 9.3 Pointers and Address
    4. 9.4 Pointer Declaration
    5. 9.5 Void Pointers
    6. 9.6 Wild Pointers
    7. 9.7 Constant Pointers
    8. 9.8 Arithmetic Operations with Pointers
    9. 9.9 Pointers and Arrays
    10. 9.10 Pointers and Two-Dimensional Arrays
    11. 9.11 Array of Pointers
    12. 9.12 Pointers to Pointers
    13. 9.13 Pointers and Strings
    14. Summary
    15. Exercises
  16. 10. Functions
    1. 10.1 Introduction
    2. 10.2 Basics of a Function
      1. 10.2.1 Why Use Functions?
      2. 10.2.2 How a Function Works?
    3. 10.3 Function Definition
    4. 10.4 The return Statement
    5. 10.5 Types of Functions
    6. 10.6 Call by Value and Reference
    7. 10.7 Function Returning More Values
    8. 10.8 Function as an Argument
    9. 10.9 Function with Operators
    10. 10.10 Function and Decision Statements
    11. 10.11 Function and Loop Statements
    12. 10.12 Functions with Arrays and Pointers
    13. 10.13 Recursion
    14. 10.14 Types of Recursion
    15. 10.15 Rules for Recursive Function
    16. 10.16 Direct Recursion
    17. 10.17 Indirect Recursion
    18. 10.18 Recursion Versus Iterations
    19. 10.19 The Towers of Hanoi
    20. 10.20 Advantages and Disadvantages of Recursion
    21. 10.21 Efficiency of Recursion
    22. 10.22 Library Function
    23. Summary
    24. Exercises
  17. 11. Storage Class
    1. 11.1 Introduction
      1. 11.1.1 Lifetime of a Variable
      2. 11.1.2 Visibility of a Variable
    2. 11.2 Automatic Variables
    3. 11.3 External Variables
    4. 11.4 Static Variables
    5. 11.5 Register Variables
    6. Summary
    7. Exercises
  18. 12. Preprocessor Directives
    1. 12.1 Introduction
    2. 12.2 The #define Directive
    3. 12.3 Undefining a Macro
    4. 12.4 Token Pasting and Stringizing Operators
    5. 12.5 The #include Directive
    6. 12.6 Conditional Compilation
    7. 12.7 The #IFNDEF Directive
    8. 12.8 The #ERROR Directive
    9. 12.9 The #LINE Directive
    10. 12.10 The #PRAGMA inline Directive
    11. 12.11 The #PRAGMA saveregs
    12. 12.12 The #PRAGMA Directive
    13. 12.13 The Predefined Macros in ANSI and TURBO-C
    14. 12.14 Standard I/O Predefined Streams in stdio.h
    15. 12.15 The Predefined Marcos in ctype.h
    16. 12.16 Assertions
    17. Summary
    18. Exercises
  19. 13. Structure and Union
    1. 13.1 Introduction
    2. 13.2 Features of Structures
    3. 13.3 Declaration and Initialization of Structures
    4. 13.4 Structure within Structure
    5. 13.5 Array of Structures
    6. 13.6 Pointer to Structure
    7. 13.7 Structure and Functions
    8. 13.8 typedef
    9. 13.9 Bit Fields
    10. 13.10 Enumerated Data Type
    11. 13.11 Union
    12. 13.12 Calling Bios and Dos Services
    13. 13.13 Union of Structures
    14. Summary
    15. Exercises
  20. 14. Files
    1. 14.1 Introduction
    2. 14.2 Streams and File Types
      1. 14.2.1 File Types
    3. 14.3 Steps for File Operations
      1. 14.3.1 Opening of File
      2. 14.3.2 Reading a File
      3. 14.3.3 Closing a File
      4. 14.3.4 Text Modes
      5. 14.3.5 Binary Modes
    4. 14.4 File I/O
    5. 14.5 Structures Read and Write
    6. 14.6 Other File Function
    7. 14.7 Searching Errors in Reading/Writing Files
    8. 14.8 Low-Level Disk I/O
    9. 14.9 Command Line Arguments
    10. 14.10 Application of Command Line Arguments
    11. 14.11 Environment Variables
    12. 14.12 I/O Redirection
    13. Summary
    14. Exercises
  21. 15. Graphics
    1. 15.1 Introduction
    2. 15.2 Initilization of Graphics
    3. 15.3 Few Graphics Functions
    4. 15.4 Programs Using Library Functions
      1. 15.4.1 Program on Moving Moon
    5. 15.5 Working with Text
      1. 15.5.1 Stylish Lines
    6. 15.6 Filling Patterns with Different Colours and Styles
    7. 15.7 Mouse Programming
    8. 15.8 Drawing Noncommon Figures
    9. Summary
    10. Exercises
  22. 16. Dynamic Memory Allocation and Linked List
    1. 16.1 Dynamic Memory Allocation
    2. 16.2 Memory Models
    3. 16.3 Memory Allocation Functions
    4. 16.4 List
    5. 16.5 Traversal of a List
    6. 16.6 Searching and Retrieving an Element
    7. 16.7 Predecessor and Successor
    8. 16.8 Insertion
    9. 16.9 Linked Lists
    10. 16.10 Linked List with and without Header
      1. 16.10.1 Linked List with Header
    11. Summary
    12. Exercises
  23. Appendix A
    1. American Standard Code for Information Interchang
  24. Appendix B
    1. Priority of Operators and Their Clubbing
  25. Appendix C
    1. Header Files and Standard Library Functions
  26. Appendix D
    1. ROM-BIOS Services
  27. Appendix E
    1. Scan Codes of Keyboard Keys
  28. Acknowledgements
  29. Copyright