Contents
■ ■ ■ ■ N K r l r h ®? /
Preface
Course Syllabus
1. Program Development Styles and Basics of C
V
x ii i
1
l.l Program Development Methodologies 1
1.2
Programming Style 3
1.3
Stepwise Refinement and Modularity 4
1.4 Problem Solving Techniques 5
1.5
Algorithm 5
1.6
Flowcharts 8
1.7
Pseudocode 13
1.8
Sequence and Selection 15
1.9
Iteration and Recursion 18
1.10
Recursion Versus Iteration 21
1.11
Overview of Compilers and Interpreters 21
1.12 Structure of a C Program 22
1.13 Programming Rules 23
1.14
Executing the Program 24
Summary 24
Exercises 24
2. The C Declarations
26
2.1 Introduction 26
2.2 The C Character Set 26
2.3
Delimiters 27
2.4
TheC Keywords 28
2.5
Identifiers 28
2.6
Constants 28
2.7 Variables 29
2.8
Rules for Defining Variables 30
2.9
C Aggregate Data Types 30
2.10
Declaring Variables 35
2.11
Initializing Variables 35
viii Contents
2.12 Type Conversion 36
Summary 37
Exercises 37
3. Operators and Expressions 40
4.
3.1 Introduction 40
3.2 Priority of Operators and their Clubbing 41
3.3 Comma and Conditional Operator 43
3.4 Arithmetic Operators 44
3.5 Relational Operators 47
3.6 Logical Operators 50
3.7 Bitwise Operators 54
Summary 60
Exercises 60
Input and Output in C 64
4.1 Introduction 64
4.2
Formatted Functions 65
4.3 Unformatted Functions 74
4.4
Commonly Used Library Functions 78
Summary 78
Exercises 79
5. Decision Statements
81
5.1
Introduction 81
5.2
The i f Statement 82
5.3 The i f . . . e lse Statement 85
5.4 Nested i f - e l s e Statement 89
5.5 The break Statement 97
5.6 The cont inue Statement 98
5.7
The goto Statement 98
5.8
The switch Statement 101
5.9 Nested sw itch () Case 113
5.10 The switch () Case and Nested i f s 116
Summary 117
Exercises 118
6. Loop Control Statements 121
6.1
Introduction 121
6.2 The fo r Loop 122
6.3 Nested fo r Loops 140
6.4 The whi le Loop 169
6.5
Thedo-while 184
6.6 Thedo-while Statement with while Loop 190
Summary 190
Exercises 191
Contents ix
7. Arrays 196
7.1 Introduction 196
7.2 Array Initialization 197
7.3 Definition of Array 197
7.4 Characteristic of Array 197
7.5 One-dimensional Array 198
7.6 Predefined Streams 212
7.7 Two-dimensional Array 216
7.8 Three- or Multi-dimensional Arrays 232
7.9 The sscanf () andsprintf () Functions 236
Summary 238
Exercises 238
8. Working with Strings & Standard Functions 242
8.1
Introduction 242
8.2
Declaration and Initialization of String 242
8.3
Display of Strings with Different Formats 244
8.4 String Standard Functions 247
8.5 Applications of Strings 271
Summary 280
Exercises 281
9. Pointers
283
9.1
Introduction 283
9.2 Features of Pointers 283
9.3
Pointer Declaration 284
9.4 Arithmetic Operations with Pointers 291
9.5
Pointers and Arrays 295
9.6 Pointers and Two-dimensional Arrays 301
9.7 Array of Pointers 302
9.8
Pointers to Pointers 304
9.9
Pointers and Strings 306
9.10
Void Pointers 312
Summary 313
Exercises 313
10. Functions
316
10.1 Introduction 316
10.2 Definition of a Function 317
10.3 Declaration of a Function 317
10.4 The Return Statement 322
10.5 Types of Functions 324
10.6 Call by Value and Reference 331
10.7 Function Returning More Values 333
10.8 Function as an Argument 334
x Contents
10.9 Functions with Arrays and Pointers 338
10.10 Recursion 346
Summary 350
Exercises 351
11. Preprocessor Directives
______________________________________ 355
11.1 Introduction 355
11.2 The #define Directive 355
11.3 Undefining a Macro 358
11.4 Token Pasting and Stringizing Operators 359
11.5 The # inc lude Directive 360
11.6 Conditional Compilation 361
11.7 The #ifndef Directive 363
11.8 The #error Directive 364
11.9 The# lin e Directive 364
11.10 Inline Directive 365
11.11 The ttpragma Saveregs 365
11.12 The #pragma Directive 365
11.13 The Predefined Macros in Ansi and Turbo C 367
11.14 Standard 1/O Predefined Streams in s td io . h 369
11.15 The Predefined Macros in ctyp e. h 370
Summary 371
Exercises 371
12. Structure and Union 375
12.1 Introduction 375
12.2
Features of Structures 375
12.3
Declaration and Initialization of Structures 376
12.4
Structure within Structure 380
12.5 Array of Structures 383
12.6
Pointer to Structure 386
12.7
Structure and Functions 389
12.8 typedef 393
12.9
Bit Fields 397
12.10 Enumerated Data Type 400
12.11 Union 405
12.12
Calling Bios and Dos Services 406
12.13 Union of Structures 412
Summary 413
Exercises 413
13. Files
417
13.1 Introduction 417
13.2
Streams and File Types 417
13.3 Steps for File Operations 418
13.4
File I/O 428
13.5
Structures Read and Write 436
Contents xl
13.6 Other File Function 440
13.7 Searching Errors in Reading/Writing Files 444
13.8 Low Level Disk I/O 455
13.9 Command Line Arguments 458
13.10 Application of Command Line Arguments 460
13.11 Environment Variables 462
13.12 I/O Redirection 463
Summary 465
Exercises 465
14. Linear Data Structure 467
14.1 Introduction to Data Structure 467
14.2 List 469
14.3 Implementation of a List 470
14.4 Traversal of a List 470
14.5 Searching and Retrieving an Element 471
14.6 Predecessor and Successor 472
14.7 Insertion 474
14.8 Deletion 476
14.9 Sorting 477
14.10 Merging Lists 478
14.11 Representation of a Stack 480
14.12 Stack-Related Terms 483
14.13 Operation on a Stack 483
14.14 Implementation of a Stack 484
14.15 Queues 488
14.16 Various Positions of Queue 489
14.17 Representation of Queue 491
14.18 Single Linked List 495
14.19 Linked List with and without Header 497
14.20 Insertion 503
14.21 Deletion 515
14.22 Double Linked List 517
14.23 Applications 527
Summary 528
Exercises 528
15. Non-Linear Data Structure 531
15.1 Trees 531
15.2 Binary Trees 531
15.3 Types of Binary Tree 533
15.4 Binary Tree Representation 534
15.5 Traversing Binary Trees 535
15.6 Binary Search Tree 544
15.7 Insertion and Deletion Operations 544
15.8 Hashing Technology 553
Summary 564
Exercises 564
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.15.154