Preface 
  1 Introduction to Computers,  Programming and the C Language   
  1.1 Computer Architecture  
  1.2 Program Development  Process  
  1.3 Structured and Modular  Programming  
  1.4 Flowcharts  
  1.4.1 Flowchart Symbols 
  1.4.2 Flowcharts for Sequencing 
  1.4.3 Flowcharts for Selection 
  1.4.4 Flowcharts for Loops   
  1.5 The C Programming  Language   
  1.5.1 C Language Standards  
  1.5.2 C Programs  
  1.6 Program Development  Environments  
  1.6.1 Turbo C/C++  
  1.6.2 Dev-C++  
  1.6.3 Code::Blocks  
  1.7 Advanced Concepts  
  1.7.1 A Quick Tour of the C  Language  
  1.7.2 Main Memory  Organization  
  1.7.3 Binary Number System  
  Exercises  
Exercises (Advanced  Concepts) 
  2 Representing Data  
  2.1 Character Set  
  2.2 Keywords  
  2.3 Basic Data Types  
  2.4 Constants  
  2.4.1 Integer Constants  
  2.4.2 Floating Constants  
  2.4.3 Character Constants  
  2.5 String Literals  
  2.6 Identifiers  
  2.7 Variables  
  2.7.1 Variable Declaration  
  2.7.2 Variable  Initialization  
  2.8 Symbolic Constants  
  2.9 Advanced Concepts  
  2.9.1 Type Suffixes  
  2.9.2 Type Modifiers  
  2.9.3 Type Qualifiers  
  2.9.4 Character Strings  
  2.9.5 Constants in Octal and  Hexadecimal Form  
  Exercises  
Exercises (Advanced  Concepts) 
  3 Arithmetic Operators and  Expressions  
  3.1 Operators  
  3.1.1 Arithmetic Operators  
  3.1.2 Precedence and  Associativity of Operators  
  3.2 Expressions  
  3.2.1 Simple Arithmetic  Expressions  
  3.2.2 Parenthesized  Expressions  
  3.2.3 Initializing Variables  Using Expressions  
  3.2.4 Constant Expressions  
  3.2.5 Avoiding Common Mistakes  While Writing C Expressions  
  3.3 Assignment  
  3.3.1 Simple Assignment  Expressions  
  3.3.2 Simple Assignment  Statement  
  3.3.3 Compound Assignments  
  3.3.4 Nested Assignments  
  3.3.5 Explicit Type  Conversion  
  3.3.6 Assignments Containing  Increment and Decrement Operators  
  3.4 Advanced Concepts  
  3.4.1 Expressions  
  3.4.2 Assignments   
  3.4.3 The Comma Operator  
  3.4.4 Operations on Strings:  Element Access and Assignment   
  Exercises  
  Exercises (Advanced  Concepts)  
  4 The C Standard Library    
  4.1 About the C Standard  Library 
  4.1.1 Header Files 
  4.1.2 Functions 
  4.2 Input and Output  Facilities 
  4.2.1 Formatted Output – the printf Function 
  4.2.2 Formatted Input – the scanf Function 
  4.2.3 Character I/O 
  4.2.4 String I/O - the gets and  puts Functions 
  4.3 Mathematical Library 
  4.3.1 Powers and Logarithms 
  4.3.2 Trigonometric and  Hyperbolic Functions 
  4.3.3 Other Mathematical  Functions 
  4.4 Advanced Concepts 
  4.4.1 Streams 
  4.4.2 Function Prototypes 
  4.4.3 Formatted Output using the printf Function 
  4.4.4 Character Classification  and Conversion 
  4.4.5 Manipulating Strings 
  4.4.6 Utility Functions 
  4.4.7 Miscellaneous  Functions 
  Exercises 
  Exercises (Advanced  Concepts) 
5 Conditional Control    
  5.1 Relational and Equality  Operators 
  5.1.1 Relational and Equality  Expressions 
  5.1.2 Evaluation of Relational  and Equality Expressions 
  5.2 The if Statement 
  5.2.1 Using Block Statements in  the if Statement 
  5.3 Logical Operators 
  5.3.1 Logical AND Operator    
  5.3.2 Logical OR Operator 
  5.3.3 Logical NOT Operator 
  5.3.4 Evaluation of Boolean  Expressions 
  5.4 Character Test,  Classification and Conversion 
  5.5 The switch Statement 
  5.6 Conditional Expression  Operator (? :) 
  5.7 Advanced Concepts 
  5.7.1 Common Mistakes in if  Statements 
  5.7.2 Common Mistakes in Boolean  Expressions 
  5.7.3 Alternative Forms of  Boolean Expressions 
  Exercises 
Exercises (Advanced  Concepts)
  6 Looping Control
  6.1 The for Loop 
  6.1.1 Using Compound Statements  in the for Loop 
  6.2 The while Loop 
  6.2.1 The while Loop for Known  Number of Iterations 
  6.2.2 Text Input Using a Loop and the getchar Function 
  6.3 The do … while Loop 
  6.4 Advanced Concepts 
  6.4.1 Variations in for Loops 
  6.4.2 Variations in the while and  do ... while Loops 
  Exercises 
Exercises (Advanced  Concepts) 
  7 Nested Control Structures
  7.1 Nested if Statements 
  7.1.1 Two-Level Nested if  Statements 
  7.1.2 Higher Level Nested if  Statements    
  7.1.3 if-else-if Statement 
  7.2 Using if Statements within  Loops 
  7.2.1 Using if Statements within  a for Loop 
  7.2.2 Using if Statements within  while and do … while Loops 
  7.3 Nested Loops 
  7.4 Nested Control Structures  involving switch Statement 
  7.5 Loop  Interruption 
  7.5.1 The break Statement 
  7.5.2 The continue Statement 
  7.6 Advanced Concepts 
  7.6.1 Logical Operators and  Nested if Statements 
  7.6.2 Nested Conditional  Expression Operators 
  Exercises 
Exercises (Advanced  Concepts)   
  8 Functions
  8.1 About Functions 
  8.1.1 Function Call 
  8.1.2 Advantages of  Functions 
  8.2 User-defined Functions 
  8.2.1 Function Definition 
  8.2.2 The return Statement 
  8.2.3 Function Declaration or  Prototype 
  8.3 Program Structure 
  8.4 Methods of Parameter  Passing 
  8.5 Recursion 
  8.6 Advanced Concepts 
  8.6.1 Function Parameter as a Loop Variable 
  8.6.2 const Parameters 
  8.6.3 Storage Classes 
  Exercises 
Exercises (Advanced  Concepts)   
  9 Vectors or One-dimensional  Arrays
  9.1 Introduction 
  9.2 One-dimensional Arrays 
  9.2.1 Array Declaration 
  9.2.2 Accessing Array  Elements 
  9.2.3 Operations on Array  Elements 
  9.2.4 Operations on Entire  Arrays 
  9.2.5 Array Initialization 
  9.3 Arrays as Function  Parameters 
  9.4 Advanced Concepts 
  9.4.1 const Vectors 
  9.4.2 Static Arrays 
  9.4.3 External or Global  Arrays 
  Exercises 
Exercises (Advanced  Concepts)   
  10 Matrices and Multidimensional  Arrays
  10.1 Two-dimensional Arrays or  Matrices 
  10.1.1 Declaration 
  10.1.2 Accessing Matrix  Elements 
  10.1.3 Operations on Matrix  Elements 
  10.1.4 Operations on Entire  Matrices 
  10.1.5 Initialization 
  10.1.6 Matrices as Function  Parameters 
  10.2 Multidimensional Arrays 
  10.2.1 Declaration 
  10.2.2 Element Access and  Operations on Elements and Entire Arrays 
  10.2.3 Initialization 
  10.2.4 Multidimensional Arrays as  Function Parameters 
  10.3 Advanced Concepts 
  10.3.1 const, static and extern Arrays 
  10.3.2 Memory Allocation 
  10.3.3 Eliminate the Row and  Column of a Square Matrix 
  10.3.4 Determinant of a Square  Matrix 
  10.3.5 Cofactor of a Matrix 
  10.3.6 Inverse of a Matrix 
  Exercises 
Exercises (Advanced  Concepts) 
  11 Pointers
  11.1 Pointer Basics 
  11.1.1 What is a Pointer? 
  11.1.2 Declaring Pointer  Variables 
  11.1.3 Address Operator (&)  and Dereference Operator (*) 
  11.1.4 Pointer Assignment and  Initialization 
  11.1.5 Simple Expressions  Involving Pointers 
  11.2 Call by Reference 
  11.3 Vectors and Pointers 
  11.3.1 Operations with Pointers  to Vector Elements 
  11.3.2 Accessing Vector Elements  by Using Array Name as a Pointer 
  11.3.3 Accessing Vector Elements  Using Another Pointer Variable 
  11.3.4 Passing a Vector to a  Function Using a Pointer 
  11.4 Advanced Concepts 
  11.4.1 The Typecast and sizeof Operators 
  11.4.2 Returning a Pointer from a  Function 
  11.4.3 Matrices and Pointers 
  11.4.4 Multidimensional Arrays  and Pointers 
  11.4.5 Pointer to a Pointer 
  11.4.6 Array of Pointers 
  11.4.7 Dynamic Memory  Management 
  11.4.8 Dynamic Arrays 
  11.4.9 Pointer to a Function 
  11.4.10 Polymorphic Functions  using void Pointer 
  11.4.11 Complex Declarations  Involving Pointers 
  Exercises 
Exercises (Advanced  Concepts) 
  12 Strings
  12.1 Processing Strings 
  12.1.1 Processing Strings Using  Loops 
  12.1.2 Writing Functions for  String Processing 
  12.2 Library Functions for String  Processing 
  12.2.1 ANSI C Standard Library  Functions for String Processing 
  12.3 Advanced Concepts 
  12.3.1 Nesting String  Manipulation Functions 
  12.3.2 Avoiding Pitfalls in  String Processing 
  12.3.3 Working with Words in a  String 
  12.3.4 ANSI Functions for Advanced  String Processing 
  12.3.5 Non-ANSI Functions for  String Processing 
  12.3.6 Dynamic Memory  Allocation 
  12.3.7 Command-Line  Arguments 
  Exercises 
Exercises (Advanced  Concepts) 
  13 Structures
  13.1 Structures 
  13.1.1 Declaring Structures 
  13.1.2 Defining Structure  Variables 
  13.1.3 Accessing Structure  Members – the Dot Operator 
  13.1.4 Structure  Initialization 
  13.1.5 Structure Assignment 
  13.1.6 Other Operations on  Structures 
  13.2 Structures and  Functions 
  13.2.1 Passing a Structure to a  Function 
  13.2.2 Structure as a Function  Value 
  13.3 Structure Containing  Arrays 
  13.3.1 Declaring Structures  Containing Arrays 
  13.3.2 Initializing Structures  Containing Arrays 
  13.3.3 Accessing Member Arrays    
  13.3.4 Accessing Elements of  Member Arrays 
  13.3.5 Using Structure Containing  Arrays as Function Parameter and Return Value 
  13.4 Nested Structures 
  13.4.1 Declaration of Nested  Structures 
  13.4.2 Initializing Nested  Structures 
  13.4.3 Processing Nested  Structures 
  13.5 Advanced Concepts 
  13.5.1 Memory Organization of  Structures 
  13.5.2 Pointer to a  Structure 
  13.5.3 Array of Structures 
  13.5.4 Representing Complex Data  Using Arrays and Structures 
  13.5.5 Structure Containing  Pointer Members 
  Exercises 
Exercises (Advanced  Concepts) 
 14 Files
  14.1 File Basics 
  14.1.1 What is a File? 
  14.1.2 Streams 
  14.1.3 Standard Library Support  for File Processing 
  14.2 File Access Functions 
  14.2.1 The fopen Function 
  14.2.2 The fclose Function  
  14.3 Character I/O 
  14.3.1 The fgetc Function and the getc Macro 
  14.3.2 The fputc Function and the putc Macro  
  14.3.3 The fgets and fputs Functions  
  14.3.4 The ungetc Function 
  14.4 Formatted I/O  
  14.5 Advanced Concepts 
  14.5.1 FILE Structure 
  14.5.2 Pagination Control in  Display of Text Files 
  14.5.3 Direct Input/Output 
  14.5.4 File Positioning  
  Exercises    
Exercises (Advanced  Concepts)  
  15 Searching and Sorting
  15.1 Searching    
  15.1.1 Linear (or Sequential)  Search 
  15.1.2 Binary Search 
  15.1.3 Recursive Binary  Search 
  15.2 Sorting 
  15.2.1 Bubble Sort 
  15.2.2 Selection Sort 
  15.2.3 Insertion Sort 
  15.3 Advanced Concepts 
  15.3.1 Alternative/Efficient  Implementations for Sorting Functions 
  15.3.2 Sorting Strings 
  15.3.3 Standard Library Functions  for Searching and Sorting 
  Exercises 
Exercises (Advanced  Concepts)  
  16 Miscellaneous Concepts
  16.1 Bitwise Operators 
  16.2 Enumerated Types    
  16.2.1 Declaring Enumerated  Types 
  16.2.2 Variables of Enumerated  Types 
  16.2.3 Specifying Values for  Enumerated Constants 
  16.2.4 Working with Enumerated  Data 
  16.3 Renaming Types Using typedef    
  16.3.1 Using typedef with Structures 
  16.3.2 Using typedef with Enumerated  Types 
  16.4 More on Library Functions  and Facilities 
  16.4.1 The printf Function 
  16.4.2 modf, frexp and ldexp Functions 
  16.4.3 Ranges of Integral Data  Types 
  16.4.4 Traditional Math  Constants 
  16.5 Advanced Concepts 
  16.5.1 Bitwise Operators 
  16.5.2 Renaming Types with typedef    
  16.5.3 Unions 
  16.5.4 Writing Multi-File  Programs 
  Exercises 
Exercises (Advanced  Concepts) 
  17 Graphics in Turbo C and Turbo  C++
  17.1 Preliminaries 
  17.1.1 Capabilities of the  Graphics Mode 
  17.1.2 Graphics Support in  TC/TC++ 
  17.1.3 Pixels and Resolution 
  17.1.4 Colours and Palettes 
  17.1.5 Graphics View   Ports and Pages 
  17.1.6 Graphics Adapters, Drivers  and Modes 
  17.1.7 Graphics Coordinate System  and CP 
  17.2 Invoking the Graphics  System 
  17.3 Setting Colours and the  Current Position (CP) 
  17.4 Drawing Graphics  Entities 
  17.4.1 Drawing Points and  Lines 
  17.4.2 Drawing Rectangles and  Polygons 
  17.4.3 Drawing Circular and  Elliptical Shapes 
  17.4.4 Setting Line Styles and  Fill Styles  
  17.4.5 Drawing Filled Rectangles  and Polygons  
  17.4.6 Drawing Filled Circular  and Elliptical Objects 
  17.5 Displaying Text   
  17.5.1 Functions to Display  Text   
  17.5.2 Setting Text  Characteristics  
  17.5.3 Enquiring Text  Attributes  
  17.6 Animation 
  17.6.1 Animation of Simple  Objects 
  17.6.2 Animation of Complex  Objects  
Exercises  
Appendix  A. The ASCII Character Set   
  Appendix  B. Summary of C Operators  
  Appendix  C. Summary of C Statements  
  Appendix  D. The C Standard Library  
  Appendix  E. Turbo C  
Index