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

Computer Fundamentals and Programming in C (RMK)

Book Description

Computer Fundamentals and Programming in C, with its abounding, extensive chapter-end questions and unique pedagogy, is structured to address the challenges faced by novices as well as amateur programmers. Assuming no prior knowledge of programming languages, the book presents the reader with a rich collection of solved examples and exercises.

Table of Contents

  1. Cover
  2. Title Page
  3. Contents
  4. Preface
  5. Part-I Computer Fundamentals
    1. 1 Basics of Computer
      1. 1.1 Introduction
      2. 1.2 Digital and Analog Computers
      3. 1.3 Characteristics of Computer
      4. 1.4 History of Computer
      5. 1.5 Generations of Computer
        1. 1.5.1 First Generation (1940 to 1956): Using Vacuum Tubes
        2. 1.5.2 Second Generation (1956 to 1963): Using Transistors
        3. 1.5.3 Third Generation (1964 to 1971): Using Integrated Circuits
        4. 1.5.4 Fourth Generation (1971 to present): Using Microprocessors
        5. 1.5.5 Fifth Generation (Present and Next): Using Artificial Intelligence
      6. 1.6 Classification of Computer
        1. 1.6.1 Microcomputers
        2. 1.6.2 Minicomputers
        3. 1.6.3 Mainframe Computers
        4. 1.6.4 Supercomputers
      7. 1.7 The Computer System
        1. 1.7.1 The Input-Process-Output Concept
        2. 1.7.2 Components of Computer Hardware
      8. 1.8 Central Processing Unit
        1. 1.8.1 Arithmetic Logic Unit
        2. 1.8.2 Registers
        3. 1.8.3 Control Unit
      9. 1.9 Memory Unit
        1. 1.9.1 Cache Memory
        2. 1.9.2 Primary Memory
        3. 1.9.3 Secondary Memory
      10. 1.10 Instruction Format
      11. 1.11 Instruction Set
      12. 1.12 Instruction Cycle
      13. 1.13 Microprocessor
      14. 1.14 Interconnecting the Units of a Computer
        1. 1.14.1 System Bus
        2. 1.14.2 Expansion Bus
        3. 1.14.3 External Ports
      15. 1.15 Performance of a Computer
      16. 1.16 Inside a Computer Cabinet
        1. 1.16.1 Motherboard
        2. 1.16.2 Ports and Interfaces
        3. 1.16.3 Expansion Slots
        4. 1.16.4 Ribbon Cables
        5. 1.16.5 Memory Chips
        6. 1.16.6 Storage Devices
        7. 1.16.7 Processor
      17. 1.17 Application of Computers
      18. 1.18 Summary
      19. Exercise Questions
      20. Additional Questions
    2. 2 Data Representation and Programming Fundamentals
      1. 2.1 Data Representation
      2. 2.2 Number System
        1. 2.2.1 Decimal Number System
        2. 2.2.2 Binary Number System
        3. 2.2.3 Octal Number System
        4. 2.2.4 Hexadecimal Number System
      3. 2.3 Conversion from Decimal to Binary, Octal, Hexadecimal
        1. 2.3.1 Converting Decimal Integer to Binary, Octal, Hexadecimal
        2. 2.3.2 Converting Decimal Fraction to Binary, Octal, Hexadecimal
        3. 2.3.3 Converting Decimal Integer.Fraction to Binary, Octal, Hexadecimal
      4. 2.4 Conversion of Binary, Octal, Hexadecimal to Decimal
      5. 2.5 Conversion of Binary to Octal, Hexadecimal
      6. 2.6 Conversion of Octal, Hexadecimal to Binary
      7. 2.7 Binary Arithmetic
        1. 2.7.1 Binary Addition
        2. 2.7.2 Binary Subtraction
      8. 2.8 Signed and Unsigned Numbers
        1. 2.8.1 Complement of Binary Numbers
      9. 2.9 Binary Data Representation
        1. 2.9.1 Fixed Point Number Representation
        2. 2.9.2 Floating Point Number Representation
      10. 2.10 Binary Coding Schemes
        1. 2.10.1 EBCDIC
        2. 2.10.2 ASCII
        3. 2.10.3 Unicode
      11. 2.11 Logic Gates
      12. 2.12 Programming Fundamentals
      13. 2.13 Program Development Life Cycle
      14. 2.14 Algorithm
      15. 2.15 Control Structures
      16. 2.16 Flowchart
        1. 2.16.1 Flowchart Symbols
        2. 2.16.2 Preparing a Flowchart
      17. 2.17 Pseudo Code
        1. 2.17.1 Preparing a Pseudo Code
      18. 2.18 Programming Paradigms
        1. 2.18.1 Structured Programming
        2. 2.18.2 Object-Oriented Programming (OOP)
        3. 2.18.3 Aspect-Oriented Programming (AOP)
      19. 2.19 Problem Formulation and Problem Solving
        1. 2.19.1 Problem Solving
        2. 2.19.2 Problem Formulation
      20. 2.20 Summary
      21. Exercise Questions
      22. Conceptual Questions and Answers
      23. Additional Questions
      24. Programming Exercise
  6. Part-II Basics of C Programming
    1. 3 Data Types, Variables and Constants
      1. 3.1 Introduction
      2. 3.2 C Standards
        1. 3.2.1 Kernighan & Ritchie (K&R) C Standard
        2. 3.2.2 ANSI C/Standard C/C89 Standard
        3. 3.2.3 ISO C/C90 Standard
        4. 3.2.4 C99 Standard
      3. 3.3 Learning Programming Language and Natural Language: An Analogy
      4. 3.4 C Character Set
      5. 3.5 Identifiers and Keywords
        1. 3.5.1 Identifiers
        2. 3.5.2 Keywords
      6. 3.6 Declaration Statement
      7. 3.7 Data Types
        1. 3.7.1 Basic/Primitive Data Types
        2. 3.7.2 Derived Data Types
        3. 3.7.3 User-defined Data Types
      8. 3.8 Type Qualifiers and Type Modifiers
        1. 3.8.1 Type Qualifiers
        2. 3.8.2 Type Modifiers
      9. 3.9 Difference Between Declaration and Definition
      10. 3.10 Data Object, L-value and R-value
        1. 3.10.1 Data Object
        2. 3.10.2 L-value
        3. 3.10.3 R-value
      11. 3.11 Variables and Constants
        1. 3.11.1 Variables
        2. 3.11.2 Constants
      12. 3.12 Structure of a C Program
        1. 3.12.1 Comments
        2. 3.12.2 Section1: Preprocessor Directive Section
        3. 3.12.3 Section 2: Global Declaration Section
        4. 3.12.4 Section 3: Functions Section
      13. 3.13 Executing a C Program
      14. 3.14 Compilation and Linking process
      15. 3.15 More Programs for Startup
      16. 3.16 Summary
      17. Exercise Questions
      18. Conceptual Questions and Answers
      19. Code Snippets
      20. Multiple-choice Questions
      21. Outputs and Explanations to Code Snippets
      22. Answers to Multiple-choice Questions
      23. Programming Exercises
      24. Test Yourself
    2. 4 Operators and Expressions
      1. 4.1 Introduction
      2. 4.2 Expressions
        1. 4.2.1 Operands
        2. 4.2.2 Operators
      3. 4.3 Simple Expressions and Compound Expressions
        1. 4.3.1 Precedence of Operators
        2. 4.3.2 Associativity of Operators
      4. 4.4 Classification of Operators
        1. 4.4.1 Classification Based on Number of Operands
        2. 4.4.2 Classification Based on Role of Operator
      5. 4.5 Combined Precedence of All Operators
      6. 4.6 Reading Strings from the Keyboard
      7. 4.7 Printing Strings on the Screen
      8. 4.8 Unformatted Functions
      9. 4.9 Summary
      10. Exercise Questions
      11. Conceptual Questions and Answers
      12. Code Snippets
      13. Multiple-choice Questions
      14. Outputs and Explanations to Code Snippets
      15. Answers to Multiple-choice Questions
      16. Programming Exercises
      17. Test Yourself
    3. 5 Decision-Making and Looping Statements
      1. 5.1 Introduction
      2. 5.2 Statements
      3. 5.3 Classification of Statements
        1. 5.3.1 Based Upon the Type of Action they Perform
        2. 5.3.2 Based Upon the Number of Constituent Statements
        3. 5.3.3 Based Upon their Role
      4. 5.4 Branching Statements
        1. 5.4.1 Selection Statements
        2. 5.4.2 if Statement
        3. 5.4.3 if-else Statement
        4. 5.4.4 Nested if Statement
        5. 5.4.5 Nested if-else Statement
        6. 5.4.6 switch Statement
        7. 5.4.7 Jump Statements
        8. 5.4.8 goto Statement
        9. 5.4.9 break Statement
        10. 5.4.10 continue Statement
        11. 5.4.11 return Statement
      5. 5.5 Iteration Statements
        1. 5.5.1 Counter-Controlled Loops
        2. 5.5.2 for Statement
        3. 5.5.3 while Statement
        4. 5.5.4 do-while Statement
        5. 5.5.5 Sentinel-Controlled Loops
        6. 5.5.6 Nested Loops
        7. 5.5.7 Semantics of break and continue Statements
      6. 5.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
  7. Part-III Arrays, Pointers and Strings
    1. 6 Arrays and Pointers
      1. 6.1 Introduction
      2. 6.2 Arrays
      3. 6.3 Single-dimensional Arrays
        1. 6.3.1 Declaration of a Single-dimensional Array
        2. 6.3.2 Usage of Single-dimensional Array
        3. 6.3.3 Memory Representation of Single-dimensional Array
        4. 6.3.4 Operations on a Single-dimensional Array
      4. 6.4 Pointers
        1. 6.4.1 Operations on Pointers
        2. 6.4.2 Arithmetic Operations (Pointer Arithmetic)
        3. 6.4.3 Relational (Comparison) Operations
        4. 6.4.4 Illegal Pointer Operations
      5. 6.5 void Pointer
        1. 6.5.1 Operations on void Pointer
      6. 6.6 Null Pointer
      7. 6.7 Relationship Between Arrays and Pointers
      8. 6.8 Scaling up the Concept
        1. 6.8.1 Array of Arrays (Multi-dimensional Arrays)
        2. 6.8.2 Two-dimensional Arrays
        3. 6.8.3 Three-dimensional Arrays
      9. 6.9 Array of Pointers
      10. 6.10 Pointer to a Pointer
      11. 6.11 Pointer to an Array
      12. 6.12 Advantages and Limitations of Arrays
      13. 6.13 Searching
        1. 6.13.1 Binary Search
      14. 6.14 Sorting
        1. 6.14.1 Selection Sort
        2. 6.14.2 Bubble Sort
        3. 6.14.3 Insertion Sort
        4. 6.14.4 Merge Sort
        5. 6.14.5 Quick Sort
        6. 6.14.6 Shell Sort
        7. 6.14.7 Radix Sort
      15. 6.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
    2. 7 Strings and Character Arrays
      1. 7.1 Introduction
      2. 7.2 Strings
      3. 7.3 Character Arrays
      4. 7.4 Importance of Terminating Null Character
      5. 7.5 String Library Functions
        1. 7.5.1 strlen Function
        2. 7.5.2 strcpy Function
        3. 7.5.3 strcat Function
        4. 7.5.4 strcmp Function
        5. 7.5.5 strcmpi Function
        6. 7.5.6 strrev Function
        7. 7.5.7 strlwr Function
        8. 7.5.8 strupr Function
        9. 7.5.9 strset Function
        10. 7.5.10 strchr Function
        11. 7.5.11 strrchr Function
        12. 7.5.12 strstr Function
        13. 7.5.13 strncpy Function
        14. 7.5.14 strncat Function
        15. 7.5.15 strncmp Function
        16. 7.5.16 strncmpi Function
        17. 7.5.17 strnset Function
      6. 7.6 List of Strings
        1. 7.6.1 Array of Strings
        2. 7.6.2 Array of Character Pointers
      7. 7.7 Command Line Arguments
      8. 7.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
  8. Part-IV Functions
    1. 8 Functions
      1. 8.1 Introduction
      2. 8.2 Functions
      3. 8.3 Classification of Functions
        1. 8.3.1 Based Upon who Develops the Function
      4. 8.4 User-defined Functions
        1. 8.4.1 Function Declaration
        2. 8.4.2 Function Definition
        3. 8.4.3 Function Invocation/Call/Use
      5. 8.5 Function with Inputs and Outputs
        1. 8.5.1 Passing Arguments by Value
        2. 8.5.2 Passing Arguments by Address/Reference
        3. 8.5.3 Returning More Than One Value Indirectly
        4. 8.5.4 Passing Arrays to Functions
        5. 8.5.5 Recursion
        6. 8.5.6 Pointers to Functions
        7. 8.5.7 Array of Function Pointers
        8. 8.5.8 Passing Function to a Function as an Argument
      6. 8.6 Library Functions
        1. 8.6.1 Declaration of Library Functions/Role of Header Files
        2. 8.6.2 Use of Library Functions
      7. 8.7 Based upon the Number of Arguments a Function Accepts
        1. 8.7.1 Fixed Argument Functions
        2. 8.7.2 Variable Argument Functions
      8. 8.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
  9. Part-V Structures and Unions
    1. 9 Structures and Unions
      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
    2. 10 Storage Class and Preprocessor Directives
      1. 10.1 Storage Duration/Lifetime of an Object
      2. 10.2 Storage Classes
        1. 10.2.1 The auto Storage Class
        2. 10.2.2 The register Storage Class
        3. 10.2.3 The static Storage Class
        4. 10.2.4 The extern Storage Class
        5. 10.2.5 The typedef Storage Class
      3. 10.3 The C Preprocessor
      4. 10.4 Translators
      5. 10.5 Phases of Translation
        1. 10.5.1 Trigraph Replacement
        2. 10.5.2 Line Splicing
        3. 10.5.3 Tokenization
        4. 10.5.4 Preprocessor Directive Handling
      6. 10.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