Balagurusamy, E.

Programming in Ansi C E. Balagurusamy - 6th ed. - New Delhi: McGraw Hill, 2013. - xii, 558 p. ill. ;

1 Overview of C
1.1 History of C 1
1.2 importance of C 3
1.3 Sample Program 1: Printing a Message 3
1.4 Sample Program 2: Adding Two Numbers 6
1.5 Sample Program 3: Interest Calculation 7
1.6 Sample Program 4: Use of Subroutines 9
1.7 Sample Program 5: Use of Math Functions 10
1.8 Basic Structure of C Programs 12
1.9 Programming Style 13
1.10 Executing a'C Program 14
1.11 Unix System 14
1.12 MS-DOS System 17
Review Questions 18
Programming Exercises 20
2 Constants, Variables, and Data Types
2.1 Introduction 22
2.2 Character Set 22
2.3 C Tokens 24
2.4 Keywords and Identifiers 24
2.5 Constants 25
2.6 Variables 29
2.7 Data Types 30
2.8 Declaration of Variables 33
2.9 Declaration of Storage Class 37
2.10 Assigning Values to Variables 38
2.11 Defining Symbolic Constants 43
2.12 Declaring a Variable as Constant 45
2.13 Declaring a Variable as Volatile 45
2.14 Overflow and Underflow of Data 45
Review Questions 48
Programming Exercises 50
3 Operators and Expressions
3.1 Introduction 52
3.2 Aritfimetic Operators 52
3.3 Relational Operators 55
3.4 Logical Operators 56
3.5 Assignment Operators 57
3.6 Increment and Decrement Operators 59
3.7 Conditional Operator 60
3.8 Bitwise Operators 60
3.9 Special Operators 61
3.10 Aritfimetic Expressions 63
3.11 Evaluation of Expressions 63
3.12 Precedence of Arithmetic Operators 64
3.13 Some Computational Problems 66
3.14 Type Conversions in Expressions 68
3.15 Operator Precedence and Associativity 71
3.16 Mathematical Functions 73
Review Questions 77
Programming Exercises 80
4 Managing Input and Output Operations
4.1 Introduction 83
4.2 Reading a Character 84
4.3 Writing a Character 87
4.4 Formatted Input 88
4.5 Formatted Output 96
Review Questions 108
Programming Exercises 110
5 Decision Making and Branching
5.1 Introduction 112
5.2 Decision Making with If Statement 112
5.3 Simple If Statement 113
5.4 The If Else Statement 116
5.5 Nesting of If....Else Statements 120
5.6 The Else If Ladder 123
5.7 The Switch Statement 127
5.8 The ? : Operator 131
5.9 The Goto Statement 135
Review Questions 143
Programming Exercises 147
6 Decision Making and Looping
6.1 Introduction 151
6.2 The while Statement 153
6.3 The do Statement 155
6.4 The for Statement 158
6.5 Jumps in Loops 168
6.6 Concise Test Expressions 176
7 Arrays
Review Questions 184
Programming Exercises 188
7.1 Introduction 192
7.2 One-Dimensional Arrays 194
7.3 Declaration of One-Dimensional Arrays 195
7.4 Initialization of One-Dimensional Arrays 197
7.5 Two-Dimensional Arrays 203
7.6 Initializing Two-Dimensional Arrays 207
7.7 Multi-Dimensional Arrays 215
7.8 Dynamic Arrays 216
7.9 More about Arrays 217
Review Questions 230
Programming Exercises 233
8 Character Arrays and Strings
8.1 Introduction 237
8.2 Declaring and Initializing String Variables 238
8.3 Reading Strings from Terminal 239
8.4 Writing Strings to Screen 245
8.5 Arithmetic Operations on Characters 249
8.6 Putting Strings Together 251
8.7 Comparison of Two Strings 252
8.8 String-Handling Functions 253
8.9 Table of Strings 259
8.10 Other Features of Strings 261
Review Questions 266
Programming Exercises 268
9 User-Defined Functions
9.1 Introduction 270
9.2 Need for User-Defined Functions 270
9.3 A Multi-Function Program 271
9.4 Elements of User-Defined Functions 274
9.5 Definition of Functions 274
9.6 Return Values and Their Types 277
9.7 Function Calls 278
9.8 Function Declaration 280
9.9 Category of Functions 281
9.10 No Arguments and No Return Values 282
9.11 Arguments but No Return Values 284
9.12 Arguments with Return Values 287
9.13 No Arguments but Retums a Value 292
9.14 Functions that Return Multiple Values 293
9.15 Nesting of Functions 294
9.16 Recursion 295
9.17 Passing Arrays to Functions 296
9.18 Passing Strings to Functions 301
9.19 The Scope, Visibility and Lifetime of Variables 302
9.20 Multifile Programs 312
Review Questions 317
Programming Exercises 321
10 , Structures and Unions
10.1 Introduction 324
10.2 Defining a Structure 324
10.3 Declaring Structure Variables 326
10.4 Accessing Structure Members 328
10.5 Structure Initialization 330
10.6 Copying and Comparing Structure Variables 331
10.7 Operations on Individual Members 333
10.8 Arrays of Structures 334
10.9 Arrays within Structures 336
10.10 Structures within Structures 338
10.11 Structures and Functions 340
10.12 Unions 343
10.13 Size of Structures 344
10.14 Bit Fields 344
Review Questions 351
Programming Exercises 355
11 Pointers
11.1 Introduction 357
11.2 Understanding Pointers 357
11.3 Accessing the Address of a Variable 360
11.4 Declaring Pointer Variables 361
11.5 Initialization of Pointer Variables 362
11.6 Accessing a Variable through its Pointer 363
11.7 Chain of Pointers 366
11.8 Pointer Expressions 366
11.9 Pointer Increments and Scale Factor 368
11.10 Pointers and Arrays 369
11.11 Pointers and Character Strings 372
11.12 Array of Pointers 374
11.13 Pointers as Function Arguments 375
11.14 Functions Returning Pointers 378
11.15 Pointers to Functions 379
11.16 Pointers and Structures 382
11.17 Troubles with Pointers 384
Review Questions 391
Programming Exercises 394
12 File Management in C
12.1 Introduction 395
12.2 Defining and Opening a File 395
12.3 Closing a File 397
12.4 Input/Output Operations on Files 398
12.5 Error Handling During I/O Operations 404
12.6 Random Access to Files 407
12.7 Command Line Arguments 414
Review Questions 416
Programming Exercises 418
13 Dynamic Memory Allocation and Linked Lists
13.1 Introduction 419
13.2 Dynamic Memory Allocation 419
13.3 Allocating a Block of Memory: Malloc 420
13.4 Allocating Multiple Blocks of Memory: Calloc 422
13.5 Releasing the used Space: Free 423
13.6 Altering the Size of a Block: Realloc 424
13.7 Concepts of Linked Lists 425
13.8 Advantages of Linked Lists 428
13.9 Types of Linked Lists 428
13.10 Pointers Revisited 429
13.11 Creating a Linked List 431
13.12 Inserting an Item 435
13.13 Deleting an Item 438
13.14 Application of Linked Lists 440
Review Questions 448
Programming Exercises 450
14 The Preprocessor
14.1 Introduction 452
14.2 Macro Substitution 453
14.3 File Inclusion 457
14.4 Compiler Control Directives 457
14.5 ANSI Additions 461
Review Questions 463
Programming Exercises 464
15 Developing a C Program: Some Guidelines
15.1 Introduction 465
15.2 Program Design 465
15.3 Program Coding 467
15.4 Common Programming Errors 469
15.5 Program Testing and Debugging 476
15.6 Program Efficiency 478
Review Questions 478

9781259004612 1259004619


Computer programming
C Programming

005.133 / BAL/P