C Programming: Learn to Code
- Length: 320 pages
- Edition: 1
- Language: English
- Publisher: Chapman and Hall/CRC
- Publication Date: 2021-12-15
- ISBN-10: 1032036257
- ISBN-13: 9781032036250
- Sales Rank: #0 (See Top 100 Books)
The C programming language is a popular language in industries as well as academics. Since its invention and standardized as ANSI C, several other standards known as C99, C11, and C17 were published with new features in subsequent years. This book covers all the traits of ANSI C and includes new features present in other standards. The content of this book helps a beginner to learn the fundamental concept of the C language. The book contains a step-by-step explanation of every program that allows a learner to understand the syntax and builds a foundation to write similar programs. The explanation clarity, exercises, and illustrations present in this book make it a complete textbook in all aspects.
Features:
- Other than ANSI C, the book explains the new C standards like C99, C11, and C17.
- Most basic and easy-to-follow programs are chosen to explain the concepts and their syntax.
- More emphasis is given to the topics like Functions, Pointers, and Structures.
- Recursion is emphasized with numerous programming examples and diagrams.
- A separate chapter on the command-line argument and preprocessors is included that concisely explains their usage.
- Several real-life figures are taken to explain the concepts of dynamic memory allocation, file handling, and the difference between structure and union.
- The book contains more than 260 illustrations, more than 200 programs, and exercises at the end of each chapter.
This book serves as a textbook for UG/PG courses in science and engineering. The researcher, postgraduate engineers, and embedded software developers can also keep this book as reference material for their fundamental learning.
Cover Half Title Title Page Copyright Page Dedication Table of Contents Preface Acknowledgments Organization of this Book Author Biography Chapter 1: Introduction to the Computer 1.1 Introduction 1.2 Definition and Characteristics of a Computer System 1.3 History of the Computer 1.4 Basic Computer Organization 1.4.1 Input Devices 1.4.2 Memory 1.4.3 Central Processing Unit 1.4.4 Output Devices 1.5 Computer Memory 1.5.1 Registers 1.5.2 Cache Memory 1.5.3 Primary Memory 1.5.4 Random Access Memory 1.5.5 Read Only Memory 1.5.6 Secondary Memory 1.5.7 Hard Disk Drive 1.5.8 Solid State Drive 1.6 Introduction to the Operating System 1.6.1 Hardware and Software 1.6.2 Operating System 1.6.3 Functions of an Operating System 1.7 Review Questions 1.7.1 Long Answers 1.7.2 Short Answers 1.7.3 Practical Exercises References Chapter 2: Number Systems 2.1 Introduction 2.1.1 Non-positional Number Systems 2.1.2 Positional Number Systems 2.2 Positional Number Systems 2.2.1 Decimal Number System 2.2.2 Binary Number System 2.2.3 Hexadecimal Number System 2.2.4 Octal Number System 2.3 Number Conversion 2.3.1 Binary to Decimal 2.3.1.1 Approach 2.3.1.2 Approach 2.3.2 Binary Fraction to Decimal Conversion 2.3.3 Binary to Decimal Conversion 2.3.4 Decimal Fraction to Binary Fraction 2.3.5 Decimal to Octal Conversion 2.3.6 Octal to Decimal Conversion 2.3.7 Octal to Binary Conversion 2.3.7.1 Procedure 2.3.7.2 Procedure 2.3.8 Binary to Octal Conversion 2.3.8.1 Procedure 2.3.8.2 Procedure 2.3.9 Decimal to Hexadecimal Conversion 2.3.10 Hexadecimal to Decimal Conversion 2.3.11 Hexadecimal to Binary Conversion 2.3.11.1 Procedure 2.3.11.2 Procedure 2.3.12 Binary to Hexadecimal Conversion 2.3.12.1 Procedure 2.3.12.2 Procedure 2.4 Review Questions 2.4.1 Conversion Questions Chapter 3: Problem Solving through Flowcharts and Algorithms 3.1 Introduction 3.2 Problem-solving Approach 3.3 Algorithm Design 3.3.1 Characteristics of an Algorithm 3.4 Basics of an Algorithm 3.4.1 Advantages of Using an Algorithm 3.4.2 Example: Write an Algorithm to Add Two Numbers and Produce the Sum 3.5 Flowcharts 3.5.1 Advantages of Using a Flowchart 3.5.2 Flowchart Symbols 3.5.3 Flowchart Drawing Guidelines 3.6 Example Problems 3.7 Basics of a Programming Language 3.7.1 Low-level Languages 3.7.1.1 Machine-level Languages 3.7.1.2 Assembly-level Languages 3.7.2 High-level Languages 3.7.2.1 Compiler vs. Interpreter 3.7.2.2 Advantages 3.8 Review Questions 3.8.1 Objective Type Questions 3.8.2 Practice Problems 3.8.3 Subjective Questions Reference Chapter 4: Introduction to C Programming 4.1 Introduction 4.2 History of C 4.3 Executing a C Program 4.3.1 Editing 4.3.2 Compiling 4.3.3 Linking 4.3.4 Executing 4.4 Structure of a C Program 4.4.1 Documentation 4.4.2 Header Files 4.4.3 Global Variables 4.4.4 main() Function 4.4.5 Subprograms 4.4.6 Your First C Program 4.5 Compilers and Editors for Executing C Programs 4.5.1 Editors 4.5.2 Compilers 4.5.3 Executing Your First C Program 4.5.3.1 Mac 4.5.3.2 Windows 4.5.3.3 Linux 4.6 Review Questions 4.6.1 Objective Questions 4.6.2 Short Answer Questions 4.6.3 Programming Questions 4.6.4 Long Questions References Chapter 5: Constants, Variables, and Data Types 5.1 Introduction 5.2 C Character Sets 5.3 Keywords 5.4 Variables and Identifiers 5.5 Data Types 5.5.1 Primary Data Types 5.5.2 Integer Data Types 5.5.3 Floating Point Types 5.5.4 Character Data Types 5.5.5 Void Types 5.6 Declaration of Variables 5.7 Constants 5.7.1 Integer Constants 5.7.2 Real Constants 5.7.3 Fractional Form 5.7.4 Exponential Form 5.7.5 Character Constants 5.7.6 String Constants 5.8 Learn to Code Examples 5.9 Escape Sequences 5.10 Review Questions 5.10.1 Objective Questions 5.10.2 Programming Questions 5.10.3 Subjective Questions Chapter 6: Operators and Expressions 6.1 Introduction 6.2 Arithmetic Operators 6.3 Relational Operators 6.4 Assignment Operators 6.5 Logical Operators 6.6 Increment and Decrement Operators 6.7 Conditional Operators 6.7.1 Nested Conditional Operators 6.8 Bitwise Operators 6.8.1 Bitwise AND, OR, XOR 6.8.2 One’s Complement (~) Operator 6.8.3 Two’s Complement Representation 6.8.4 Left Shift Operator (≪) and Right Shift Operator (≫) 6.9 Special Operators 6.9.1 The Comma Operator 6.9.2 The sizeof Operator 6.10 Expressions 6.10.1 Evaluation of Expressions 6.10.2 Rules for Evaluation of Expressions 6.11 Type Conversion 6.11.1 Implicit Type Casting 6.11.2 Explicit Type Conversion 6.12 Operator Precedence and Associativity 6.13 Review Questions 6.13.1 Objective Type Questions 6.13.2 Programming Questions 6.13.3 Subjective Type Questions Chapter 7: Basic Input/Output 7.1 Introduction 7.2 Unformatted Functions 7.2.1 getchar() and putchar() 7.2.2 gets() and puts() 7.2.3 getch() and getche() 7.2.4 putch() 7.3 Formatted Functions 7.3.1 printf() Function 7.3.2 Formatting with printf() 7.3.3 scanf() Function 7.3.4 Formatting with scanf 7.4 Review Questions 7.4.1 Short Answer Questions 7.4.2 Programming Questions 7.4.3 Subjective Questions Chapter 8: Control Structures 8.1 Introduction 8.2 Selection with if Statements 8.2.1 Some Points to Remember 8.3 if-else Statement 8.3.1 Write a Program to Check Whether a Number Entered by the User is Zero or Nonzero 8.3.2 Write a Program to Calculate the Travel Fare of a Person 8.4 Nested if-else Statements 8.4.1 Write a Program to Find the Biggest Among Three Numbers 8.5 if-else-if Ladders 8.5.1 Write a Program to Perform as a Four-Function Calculator 8.6 Compound Statements 8.7 Multiway Selection with Switch Statements 8.7.1 Some Points to Remember 8.8 goto Statement 8.8.1 Notes on goto 8.9 Introduction to Loops 8.10 while Loops 8.11 do-while Loops 8.11.1 Difference Between while and do-while Loops 8.12 for Loops 8.12.1 Some Solved Problems (Printing Patterns) 8.13 Unconditional Branching: break and continue 8.13.1 break Statements 8.13.2 continue Statements 8.14 Review Questions 8.14.1 Short Questions 8.14.2 Long Questions Chapter 9: Functions 9.1 Introduction 9.2 The Need for Functions 9.3 Types of Function 9.4 User-defined Functions 9.5 Components and Working of a Function 9.5.1 Calling Function 9.5.2 Called Function 9.5.3 Function Prototype 9.5.4 Function Definition 9.5.5 Function Call 9.5.6 Actual Arguments 9.5.7 Formal Arguments 9.5.8 Return Type 9.6 Categories of a Function 9.6.1 A Function Without Arguments and Without Return Types 9.6.2 A Function Without Arguments and With Return Types 9.6.3 A Function With Arguments and Without Return Types 9.6.4 A Function With Arguments and With Return Types 9.7 Recursion 9.7.1 Example: Find the Value of x y 9.7.2 Programming Examples 9.8 Storage Classes 9.8.1 Automatic Storage Class 9.8.2 Register Storage Class 9.8.3 Static Storage Class 9.8.4 External Storage Class 9.9 Review Questions 9.9.1 Objective Questions 9.9.2 Subjective Questions 9.9.3 Programming Questions Chapter 10: Arrays and Strings 10.1 Introduction 10.2 Need for Arrays 10.3 Types of Arrays 10.4 1D Arrays 10.4.1 Declaration of 1D Arrays 10.4.2 Initialization of Arrays 10.4.3 Accessing Array Elements 10.4.4 Characteristics of an Array 10.4.5 Entering Data in an Array 10.4.6 Displaying the Content of an Array 10.4.7 Programming Examples 10.4.7.1 Write a Program to Create an Array of N Elements and Write the Code to Find the Biggest Number and the Smallest Number Present in the Array 10.4.7.2 Write a Program to Search for an Element Present in the Array, the Number of Times the Element is Present, and Print the Element’s Positions 10.4.7.3 Write a Program to Print the Binary Equivalent of a Decimal Number Using an Array 10.4.8 Points to Note 10.5 2D Arrays 10.5.1 Introducing Matrices 10.5.2 Declaration of a 2D Array 10.5.3 Representation of a 2D Array in Memory 10.5.3.1 Row Major Order 10.5.3.2 Column Major Order 10.5.4 Initialization of a 2D Array 10.5.5 Accessing the Elements of a 2D Array 10.5.6 Entering Data in a 2D Array 10.5.7 Exploration of a 2D Matrix 10.5.8 Programming Examples 10.5.8.1 Write a Program to Add All the Elements Present in the Main Diagonal of a 2D Matrix 10.5.8.2 Write a Program to Add the Elements of Each Column and Print it in the Following Format 10.5.8.3 Write a Program to Add Two Matrices 10.5.8.4 Write a Program to Multiply Two Matrices 10.6 Multidimensional Arrays 10.6.1 Declaration and Representation of 3D Arrays 10.6.1.1 Write a Program to Declare a 3D Array, Input Some Numbers, and Display the 3D Array 10.7 Character Arrays: Strings 10.7.1 Declaration of a String 10.7.2 Initialization of a String 10.7.3 Reading a String 10.7.3.1 Disadvantages of the scanf() Function 10.7.3.2 Reading Strings with the gets() Function 10.7.4 Displaying the String 10.7.5 Programming Examples 10.7.5.1 Find the Length of a String 10.7.5.2 Count the Number of Words Present in a String 10.7.5.3 Reverse the String 10.7.5.4 Check Whether the String is a Palindrome or Not 10.8 String Functions 10.8.1 strcpy (Destination, Source) 10.8.2 strcat (Destination, Source) 10.8.3 strcmp (First, Second) 10.8.4 Programming Examples Using String Functions 10.9 Review Questions 10.9.1 Objective Questions 10.9.2 Subjective Questions 10.9.3 Programming Exercises Chapter 11: Pointers 11.1 Introduction 11.2 Basic Knowledge 11.3 Pointer Variables 11.3.1 Declaration of Pointer Variables 11.3.2 Working with Pointers 11.3.3 Workout 11.4 Pointer to Pointer (Double Pointer) 11.5 Void Pointers 11.6 Null Pointers 11.6.1 What is the Meaning of NULL? 11.7 Constant Pointers 11.7.1 Pointers to Constants 11.8 Pointer Arithmetic 11.9 Pointers and Functions 11.9.1 Pass by Value 11.9.2 Pass by Reference or Address 11.9.2.1 Problem: Write a Program to Swap Two Numbers Using Functions 11.10 Pointers and Arrays 11.11 Passing Arrays to Functions 11.11.1 Write a Program to Pass an Array to a Function and Find the Largest and Smallest Numbers Present in that Array 11.12 Pointers and 2D Arrays 11.13 Pointers and Strings 11.13.1 Passing a String to a Function 11.13.2 Write a Program to Reverse a String Using a Function 11.14 An Array of Pointers 11.15 Pointers to Functions 11.16 Review Questions 11.16.1 Objective Questions 11.16.2 Subjective Questions 11.16.3 Programming Exercises Chapter 12: Structures and Unions 12.1 Introduction 12.2 Declaring a Structure 12.2.1 Tagged Structure Declaration 12.2.2 Structure Declaration Using typedef 12.2.3 Declaring Structure Variables 12.2.3.1 Declaring Structure Variables Using the Structure Name 12.2.3.2 Declaring Structure Variables after the Closing Braces 12.3 Initializing a Structure 12.4 Accessing Structure Members 12.4.1 Accessing Members Using the dot (.) Operator 12.5 Learn to Code Examples 12.6 Arrays of Structures 12.7 Structures within Structures (Nested Structures) 12.7.1 Declaration of Nested Structures 12.7.1.1 Declare the Structure with One Declaration 12.7.1.2 Declare the Structure Separately 12.7.2 Accessing the Members of a Nested Structure 12.7.3 Nested Structure Initialization 12.8 User-defined Data Type: typedef 12.8.1 Uses of typedef 12.9 Pointers and Structures 12.9.1 Accessing Structure Members Using a Pointer 12.9.2 A Pointer as a Member of a Structure 12.9.3 Self-referential Structures 12.10 Structures and Functions 12.10.1 Passing Individual Members of a Structure 12.10.2 Passing the Whole Structure Using the Pass by Value Concept 12.10.3 Passing the Whole Structure Using the Pass by Address Concept 12.11 Unions 12.11.1 Declaration of a Union 12.11.2 Member Accessing 12.12 Structures vs. Unions 12.12.1 Size of Unions and Structures 12.12.2 Sharing Memory and Member Accessing 12.13 Bitfields 12.13.1 Declaration of a Bitfield 12.13.2 Uses of Bitfields 12.14 Enumeration 12.15 Review Questions 12.15.1 Objective Questions 12.15.2 Subjective Questions 12.15.3 Programming Exercises Chapter 13: Dynamic Memory Allocation 13.1 Introduction 13.1.1 Process of Memory Allocation 13.1.1.1 Text Segments 13.1.1.2 Data Segments 13.1.1.3 Stack Segments 13.1.1.4 Heap Segments 13.2 Types of Memory Allocation 13.2.1 Static Memory Allocation 13.2.2 Dynamic Memory Allocation 13.3 Dynamic Memory Allocation Process 13.3.1 The malloc() Function 13.3.2 The calloc() Function 13.3.3 The realloc() Function 13.3.4 The free() Function 13.4 Review Questions Chapter 14: File Handling 14.1 Introduction 14.1.1 Difference between Console I/O and File I/O 14.2 Basics of File I/O 14.2.1 What is a File? 14.2.2 File Handling Process Flow 14.3 Opening a File 14.4 Closing a File 14.5 File Functions with Examples 14.5.1 The fprintf() and fscanf() Functions 14.5.1.1 Writing and Reading an Integer Using fprintf() and fscanf() 14.5.2 The putw() and getw() Functions 14.5.2.1 Writing and Reading More than One Integer Using the putw() and getw() Functions 14.5.2.2 Reading Numbers from a File and Checking Them for Even or Odd 14.5.3 The fputc() and fgetc() Functions 14.5.3.1 Writing and Reading a Character Using fputc() and fgetc() 14.5.3.2 Writing and Reading Multiple Characters Using fputc() and fgetc() 14.5.3.3 Count Number of Characters, Lines, Tabs, and Blank Spaces Present in a File 14.5.4 The fputs() and fgets() Functions 14.5.4.1 Writing and Reading a String Using fputs() and fgets() 14.6 Other Programming Examples 14.7 Review Questions Chapter 15: The Preprocessor 15.1 Introduction 15.2 Preprocessor Directives 15.3 Macro-substitutions 15.3.1 Writing Macros with Arguments 15.3.2 Removing a Macro 15.4 The include Preprocessor 15.5 Conditional Preprocessors 15.5.1 The ifdef and endif Preprocessor Directives 15.5.2 The ifndef and endif Directives 15.5.3 The if and endif Directives 15.6 Other Preprocessor Directives 15.6.1 line Directives 15.6.2 error Directives 15.6.3 pragma Directives 15.7 Review Questions Chapter 16: Command Line Arguments 16.1 Introduction 16.1.1 The Code::Block IDE 16.2 Execute a Program Using a Command Prompt 16.2.1 Installing the minGW Compiler 16.2.2 Compiling and Executing a Program 16.3 Fundamentals of the Command Line Argument 16.4 Using Command Line Arguments 16.5 Review Questions Appendix A: ASCII Character Table: Appendix B: Integer Representation: B.1 Introduction B.2 Representation Type B.2.1 Sign-magnitude Representation B.2.1.1 Demerits of Sign-magnitude Representation B.2.2 One’s Complement Representation B.2.2.1 Demerits of One’s Complement Representation B.2.3 Two’s Complement Representation Index
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.