O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming in C, 3/e, 3rd Edition

Book Description

C is one of the most popular programming languages. It runs on most software platforms and computer architecture. This revised edition of our best-selling text Programming in C not only maintains the exclusivity of previous editions but also enhances it with the addition of new programs and illustrations. Challenging concepts are supported with numerous solved and unsolved programs. The new chapter on computer graphics ensures that this book comprehensively covers the syllabi of most universities. The book also uses the Turbo C compiler, which is the most widely used C compiler. With its increased coverage and inclusion of new learning tools, this edition is an invaluable asset for students who aim to improve their programming skills.

Table of Contents

  1. Cover
  2. Title page
  3. Contents
  4. About the Authors
  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 Algorithm
      1. 1.15.1 Program Design
    16. 1.16 Classification of Algorithms
    17. 1.17 Flow charts
    18. 1.18 Pseudocode
    19. Summary
    20. 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 Operator Precedence
    3. 3.3 Associativity
    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 Flags, Widths and Precision with Format String
    4. 4.4 Unformatted Functions
    5. 4.5 Commonly Used Library Functions
    6. 4.6 Strong Points for Understandability
    7. Summary
    8. 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 Statements
    5. 5.5 The 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 The for Loop
    3. 6.3 Nested for Loops
    4. 6.4 The while Loop
    5. 6.5 The do-while Loop
    6. 6.6 The while Loop within the do-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 Declaration
    3. 7.3 Array Initialization
    4. 7.4 Array Terminology
    5. 7.5 Characteristics of an Array
    6. 7.6 One-Dimensional Array
    7. 7.7 One-Dimensional Array and Operations
    8. 7.8 Operations with Arrays
    9. 7.9 Predefined Streams
    10. 7.10 Two-Dimensional Array and Operations
      1. 7.10.1 Insert Operation with Two-Dimensional Array
      2. 7.10.2 Delete Operation with Two-Dimensional Array
    11. 7.11 Three- or Multi-Dimensional Arrays
    12. 7.12 The sscanf() and sprintf() Functions
    13. 7.13 Drawbacks of Linear Arrays
    14. Summary
    15. 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 Functions
    6. 8.6 Memory Functions
    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 The 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 Pointers and Multi-Dimensional Arrays
    12. 9.12 Array of Pointers
    13. 9.13 Pointers to Pointers
    14. 9.14 Pointers and Strings
    15. Summary
    16. 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 Passing Array to a Function
    14. 10.14 Nested Functions
    15. 10.15 Recursion
    16. 10.16 Types of Recursion
    17. 10.17 Rules for Recursive Function
    18. 10.18 Direct Recursion
    19. 10.19 Indirect Recursion
    20. 10.20 Recursion Versus Iterations
    21. 10.21 The Towers of Hanoi
    22. 10.22 Advantages and Disadvantages of Recursion
    23. 10.23 Efficiency of Recursion
    24. 10.24 Library Functions
    25. Summary
    26. Exercises
  17. 11 Storage Classes
    1. 11.1 Introduction
      1. 11.1.1 Life time 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 Static External Variables
    6. 11.6 Register Variables
    7. Summary
    8. 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 of a File
    2. 14.2 Definition of File
    3. 14.3 Streams and File Types
      1. 14.3.1 File Types
      2. 14.4 Steps for File Operations
      3. 14.4.1 Opening of File
      4. 14.4.2 Reading a File
      5. 14.4.3 Closing a File
      6. 14.4.4 Text Modes
      7. 14.4.5 Binary Modes
    4. 14.5 File I/O
    5. 14.6 Structures Read and Write
    6. 14.7 Other File Function
    7. 14.8 Searching Errors in Reading/Writing Files
    8. 14.9 Low-Level Disk I/O
    9. 14.10 Command Line Arguments
    10. 14.11 Application of Command Line Arguments
    11. 14.12 Environment Variables
    12. 14.13 I/O Redirection
    13. Summary
    14. Exercises
  21. 15 Graphics
    1. 15.1 Introduction
    2. 15.2 Initialization 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 Non-common 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
    11. 16.10.1 Linked List with Header
    12. Summary
    13. Exercises
  23. Appendix A
    1. American Standard Code for Information Interchange
  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
  30. Back Cover