You are previewing Programming in C: A Practical Approach, First Edition.
O'Reilly logo
Programming in C: A Practical Approach, First Edition

Book Description

This book has a perfect blend of theory as well as practicals and it has been presented in a manner that helps the readers to learn the concepts through practice and programming.

Table of Contents

  1. Cover
  2. Title page
  3. Contents
  4. About the Author
  5. Dedication
  6. Preface
  7. Chapter 1. Data Types, Variables and Constants
    1. 1.1 Introduction
    2. 1.2 C Standards
      1. 1.2.1 Kernighan & Ritchie (K&R) C Standard
      2. 1.2.2 ANSI C/Standard C/C89 Standard
      3. 1.2.3 ISO C/C90 Standard
      4. 1.2.4 C99 Standard
    3. 1.3 Learning Programming Language and Natural Language: An Analogy
    4. 1.4 C Character Set
    5. 1.5 Identifiers and Keywords
      1. 1.5.1 Identifiers
      2. 1.5.2 Keywords
    6. 1.6 Declaration Statement
    7. 1.7 Data Types
      1. 1.7.1 Basic/Primitive Data Types
      2. 1.7.2 Derived Data Types
      3. 1.7.3 User-defined Data Types
    8. 1.8 Type Qualifiers and Type Modifiers
      1. 1.8.1 Type Qualifiers
      2. 1.8.2 Type Modifiers
    9. 1.9 Difference Between Declaration and Definition
    10. 1.10 Data Object, L-value and R-value
      1. 1.10.1 Data Object
      2. 1.10.2 L-value
      3. 1.10.3 R-value
    11. 1.11 Variables and Constants
      1. 1.11.1 Variables
      2. 1.11.2 Constants
    12. 1.12 Structure of a C Program
      1. 1.12.1 Comments
      2. 1.12.2 Section1: Preprocessor Directive Section
      3. 1.12.3 Section 2: Global Declaration Section
      4. 1.12.4 Section 3: Functions Section
    13. 1.13 Executing a C Program
    14. 1.14 More Programs for Startup
    15. 1.15 Summary
    16. Exercise Questions
    17. Conceptual Questions and Answers
    18. Code Snippets
    19. Multiple-choice Questions
    20. Outputs and Explanations to Code Snippets
    21. Answers to Multiple-choice Questions
    22. Programming Exercises
    23. Test Yourself
  8. Chapter 2. Operators and Expressions
    1. 2.1 Introduction
    2. 2.2 Expressions
      1. 2.2.1 Operands
      2. 2.2.2 Operators
    3. 2.3 Simple Expressions and Compound Expressions
      1. 2.3.1 Precedence of Operators
      2. 2.3.2 Associativity of Operators
    4. 2.4 Classification of Operators
      1. 2.4.1 Classification Based on Number of Operands
      2. 2.4.2 Classification Based on Role of Operator
    5. 2.5 Combined Precedence of All Operators
    6. 2.6 Summary
    7. Exercise Questions
    8. Conceptual Questions and Answers
    9. Code Snippets
    10. Multiple-choice Questions
    11. Outputs and Explanations to Code Snippets
    12. Answers to Multiple-choice Questions
    13. Programming Exercises
    14. Test Yourself
  9. Chapter 3. Statements
    1. 3.1 Introduction
    2. 3.2 Statements
    3. 3.3 Classification of Statements
      1. 3.3.1 Based Upon the Type of Action they Perform
      2. 3.3.2 Based Upon the Number of Constituent Statements
      3. 3.3.3 Based Upon their Role
    4. 3.4 Summary
    5. Exercise Questions
    6. Conceptual Questions and Answers
    7. Code Snippets
    8. Multiple-choice Questions
    9. Outputs and Explanations to Code Snippets
    10. Answers to Multiple-choice Questions
    11. Programming Exercises
    12. Test Yourself
  10. Chapter 4. Arrays and Pointers
    1. 4.1 Introduction
    2. 4.2 Arrays
    3. 4.3 Single-dimensional Arrays
      1. 4.3.1 Declaration of a Single-dimensional Array
      2. 4.3.2 Usage of Single-dimensional Array
      3. 4.3.3 Memory Representation of Single-dimensional Array
      4. 4.3.4 Operations on a Single-dimensional Array
    4. 4.4 Pointers
      1. 4.4.1 Operations on Pointers
      2. 4.4.2 void pointer
      3. 4.4.3 Null Pointer
    5. 4.5 Relationship Between Arrays and Pointers
    6. 4.6 Scaling up the Concept
      1. 4.6.1 Array of Arrays (Multi-dimensional Arrays)
      2. 4.6.2 Array of Pointers
      3. 4.6.3 Pointer to a Pointer
      4. 4.6.4 Pointer to an Array
    7. 4.7 Advantages and Limitations of Arrays
    8. 4.8 Summary
    9. Exercise Questions
    10. Conceptual Questions and Answers
    11. Code Snippets
    12. Multiple-choice Questions
    13. Outputs and Explanations to Code Snippets
    14. Answers to Multiple-choice Questions
    15. Programming Exercises
    16. Test Yourself
  11. Chapter 5. Functions
    1. 5.1 Introduction
    2. 5.2 Functions
    3. 5.3 Classification of Functions
      1. 5.3.1 Based Upon who Develops the Function
      2. 5.3.2 Based Upon the Number of Arguments a Function Accepts
    4. 5.4 Summary
    5. Exercise Questions
    6. Conceptual Questions and Answers
    7. Code Snippets
    8. Multiple-choice Questions
    9. Outputs and Explanations to Code Snippets
    10. Answers to Multiple-choice Questions
    11. Programming Exercises
    12. Test Yourself
  12. Chapter 6. Strings and Character Arrays
    1. 6.1 Introduction
    2. 6.2 Strings
    3. 6.3 Character Arrays
    4. 6.4 Reading Strings from the Keyboard
    5. 6.5 Printing Strings on the Screen
    6. 6.6 Importance of Terminating Null Character
    7. 6.7 String Library Functions
      1. 6.7.1 Strlen Function
      2. 6.7.2 Strcpy Function
      3. 6.7.3 Strcat Function
      4. 6.7.4 Strcmp Function
      5. 6.7.5 Strcmpi Function
      6. 6.7.6 Strrev Function
      7. 6.7.7 Strlwr Function
      8. 6.7.8 Strupr Function
      9. 6.7.9 Strset Function
      10. 6.7.10 Strchr Function
      11. 6.7.11 Strrchr Function
      12. 6.7.12 Strstr Function
      13. 6.7.13 Strncpy Function
      14. 6.7.14 Strncat Function
      15. 6.7.15 Strncmp Function
      16. 6.7.16 Strncmpi Function
      17. 6.7.17 Strnset Function
    8. 6.8 List of Strings
      1. 6.8.1 Array of strings
      2. 6.8.2 Array of Character Pointers
    9. 6.9 Command Line Arguments
    10. 6.10 Summary
    11. Exercise Questions
    12. Conceptual Questions and Answers
    13. Code Snippets
    14. Multiple-choice Questions
    15. Outputs and Explanations to Code Snippets
    16. Answers to Multiple-choice Questions
    17. Programming Exercises
    18. Test Yourself
  13. Chapter 7. Scope, Linkage, Lifetime and Storage Classes
    1. 7.1 Introduction
    2. 7.2 Scope
      1. 7.2.1 Determination of Scope of an Identifier
      2. 7.2.2 Termination of Scope of an Identifier
      3. 7.2.3 Same Scope
      4. 7.2.4 Visibility of an Identifier
    3. 7.3 Linkage
      1. 7.3.1 External linkage
      2. 7.3.2 Internal Linkage
      3. 7.3.3 No Linkage
    4. 7.4 Storage Duration/Lifetime of an Object
    5. 7.5 Storage Classes
      1. 7.5.1 The auto Storage Class
      2. 7.5.2 The register Storage Class
      3. 7.5.3 The static Storage Class
      4. 7.5.4 The extern Storage Class
      5. 7.5.5 The typedef Storage Class
    6. 7.6 Dynamic Memory Allocation
      1. 7.6.1 Memory Leak
    7. 7.7 Summary
    8. Exercise Questions
    9. Conceptual Questions and Answers
    10. Code Snippets
    11. Multiple-choice Questions
    12. Outputs and Explanations to Code Snippets
    13. Answers to Multiple-choice Questions
    14. Programming Exercises
    15. Test Yourself
  14. Chapter 8. The C Preprocessor
    1. 8.1 Introduction
    2. 8.2 Translators
    3. 8.3 Phases of Translation
      1. 8.3.1 Trigraph Replacement
      2. 8.3.2 Line Splicing
      3. 8.3.3 Tokenization
      4. 8.3.4 Preprocessor Directive Handling
    4. 8.4 Summary
    5. Exercise Questions
    6. Conceptual Questions and Answers
    7. Code Snippets
    8. Multiple-choice Questions
    9. Outputs and Explanations to Code Snippets
    10. Answers to Multiple-choice Questions
    11. Programming Exercises
    12. Test Yourself
  15. Chapter 9. Structures, Unions, Enumerations and Bit-fields
    1. 9.1 Introduction
    2. 9.2 Structures
      1. 9.2.1 Defining a Structure
      2. 9.2.2 Declaring Structure Objects
      3. 9.2.3 Operations on Structures
    3. 9.3 Pointers to Structures
      1. 9.3.1 Declaring Pointer to a Structure
      2. 9.3.2 Accessing Structure Members Via a Pointer to a Structure
    4. 9.4 Array of Structures
    5. 9.5 Structures within a Structure (Nested Structures)
    6. 9.6 Functions and Structures
      1. 9.6.1 Passing Each Member of a Structure Object as a Separate Argument
      2. 9.6.2 Passing a Structure Object by Value
      3. 9.6.3 Passing a Structure Object by Address/Reference
    7. 9.7 Typedef and Structures
    8. 9.8 Unions
    9. 9.9 Practical Application of Unions
      1. 9.9.1 Calling DOS and BIOS Functions
      2. 9.9.2 Interrupt Programming
    10. 9.10 Enumerations
    11. 9.11 Bit-Fields
    12. 9.12 Summary
    13. Exercise Questions
    14. Conceptual Questions and Answers
    15. Code Snippets
    16. Multiple-choice Questions
    17. Outputs and Explanations to Code Snippets
    18. Answers to Multiple-choice Questions
    19. Programming Exercises
    20. Test Yourself
  16. Chapter 10. Files
    1. 10.1 Introduction
    2. 10.2 Files
    3. 10.3 Streams
    4. 10.4 I/O Using Streams
      1. 10.4.1 Opening a Stream
      2. 10.4.2 Closing Streams
      3. 10.4.3 Character Input
      4. 10.4.4 Character Output
      5. 10.4.5 File Position Indicator
      6. 10.4.6 End of File and Errors
      7. 10.4.7 Line Input
      8. 10.4.8 Line Output
      9. 10.4.9 Formatted Input
      10. 10.4.10 Formatted Output
      11. 10.4.11 Block Input
      12. 10.4.12 Block Output
      13. 10.4.13 Stream Buffering and Flushing the Streams
    5. 10.5 File Type
    6. 10.6 Files and Command Line Arguments
    7. 10.7 Summary
    8. Exercise Questions
    9. Conceptual Questions and Answers
    10. Code Snippets
    11. Multiple-choice Questions
    12. Outputs and Explanations to Code Snippets
    13. Answers to Multiple-choice Questions
    14. Programming Exercises
    15. Test Yourself
  17. Appendix A: Number Systems
    1. A.1 Number systems
    2. A.2 Number System Conversions
      1. A.2.1 Conversion from Decimal Number System to any Other Number System
      2. A.2.2 Conversion from Any Other Number System to Decimal Number System
      3. A.2.3 Conversion from Binary Number System to Octal and Hexadecimal Number System
      4. A.2.4 Conversion from Octal and Hexadecimal Number System to Binary Number System
  18. Appendix B: Algorithms and Flowcharts
    1. B.1 Algorithm
    2. B.2 Flowcharts
  19. Appendix C: Translation Limits
  20. Appendix D: ROM-BIOS and DOS Services
  21. Appendix E: Graphics Programming
    1. E.1 Computer Graphics
    2. E.2 Initializing Graphics Mode in Turbo C 3.0
    3. E.3 Drawing Basic Shapes
      1. E.3.1 Simple Line Drawing
      2. E.3.2 Stylish Line Drawing
      3. E.3.3 Drawing Other Basic Shapes
    4. E.4 Region Filling
      1. E.4.1 Filling Regions with Different Patterns and Colors
    5. E.5 Pattern Drawing Based on Regular Polygons
      1. E.5.1 Drawing Rosettes
      2. E.5.2 Swirling Polygons
    6. E.6 Motif and Tiling
    7. E.7 Viewport and Clipping
  22. Appendix F: Answers to Test Yourself Questions
  23. Acknowledgements
  24. Copyright