{
  "C Introduction": [
    {
      "title": "Introduction to C",
      "description": "C is a general-purpose programming language that was developed by Dennis Ritchie at Bell Laboratories in 1972. It’s a powerful, popular, and high-level language known for its speed, simplicity, and flexibility",
      "sub_description": "C has played a major role in the development of core systems like operating systems, databases, and various software applications. It’s strongly associated with UNIX, as it was originally created to develop the UNIX operating system.",
      "additional_info": "Over the decades, it has grown into a widely used language and is now recognized as one of the most essential in the programming world.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Why Learn C?"
        },
        {
          "type": "list",
          "items": [
            "<b> Foundation of Programming:</b> - Learning C gives you a solid base for understanding how programming works at a deeper level.",
            "<b> Syntax Similarity:</b> - Once you learn C, picking up other popular languages like C++, Java, Python, or C# becomes much easier due to their similar syntax.",
            "<b> Understanding Memory:</b> - C teaches you how computer memory and hardware work, which is crucial for efficient programming.",
            "<b> High Speed:</b> - C is known for its speed and performance, often outperforming higher-level languages in execution.",
            "<b> Versatile Use:</b> - Whether you're building a desktop application or embedded systems, C is incredibly versatile and reliable."
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "History and Importance of C"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "A Little Backstory: How C Language Came Into Existence"
        },
        {
          "type": "paragraph",
          "text": "Let’s go back to the early 1970s—a time when computers were huge, and programming was just starting to grow fast."
        },
        {
          "type": "paragraph",
          "text": "At Bell Labs, a brilliant computer scientist named Dennis Ritchie created a new programming language called C. It was designed to help write operating systems more efficiently, especially the popular Unix operating system. Before C, people were using a language called B (yes, just the letter B!), and C came as its powerful upgrade."
        },
        {
          "type": "paragraph",
          "text": "C quickly became popular because it was simple, fast, and flexible. In 1978, Dennis Ritchie and Brian Kernighan published a book called The C Programming Language, which became the bible for C learners."
        },
        {
          "type": "paragraph",
          "text": "Since then, C has gone through updates and versions like ANSI C, C99, and C11, but its original style is still used and respected even today."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Why C Language Still Matters"
        },
        {
          "type": "paragraph",
          "text": "You might be wondering — with so many new languages around, why is C still important? Here's why:"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "1. It Helps You Talk to the Computer"
        },
        {
          "type": "paragraph",
          "text": "C gives you more control over the computer’s memory and hardware than most other languages. That’s why it’s used in places where performance matters — like operating systems, embedded systems, and even game development."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "2. It Teaches You the Basics of Programming"
        },
        {
          "type": "paragraph",
          "text": "If you’re new to programming, learning C is like learning how to drive with a manual gear car. It might seem tough at first, but it helps you understand how things work under the hood. Once you learn C, picking up languages like Python, Java, or C++ becomes much easier."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "3. It’s Super Fast"
        },
        {
          "type": "paragraph",
          "text": "Programs written in C run very fast because the code is close to the computer’s machine language. That’s why many professional software and systems are still built in C."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "4. It’s Everywhere"
        },
        {
          "type": "paragraph",
          "text": "Did you know that parts of Windows, Linux, Android, and macOS are written in C? Even modern programming languages often use C in the background. So even if you’re not writing in C daily, it’s still quietly doing its job behind the scenes."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "5. Perfect for Students and Beginners6"
        },
        {
          "type": "paragraph",
          "text": "Most schools and colleges teach C first. That’s because it covers all the core programming concepts like: "
        },
        {
          "type": "list",
          "items": [
            "Loops and conditions",
            "Datatypes",
            "Functions",
            "Array and Pointers"
          ]
        },
        {
          "type": "paragraph",
          "text": "Learning C helps you become a confident programmer who knows how computers really work."
        }
      ]
    },
    {
      "title": "Features and Applications of C Language",
      "description": "C is a powerful and versatile programming language that has stood the test of time. Here are some of its key features and applications:",
      "content": [
        {
          "type": "heading",
          "level": "4",
          "text": "1. Simple and Easy to Learn"
        },
        {
          "type": "paragraph",
          "text": "The syntax of C is clean and straightforward.Once you understand the basics, writing and reading C code becomes easy."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Fast and Efficient"
        },
        {
          "type": "paragraph",
          "text": "C programs run very quickly because the language is close to machine-level instructions.That’s why it's great for building performance-critical applications."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Structured Programming"
        },
        {
          "type": "paragraph",
          "text": "C supports structured programming — you can break your code into smaller parts using functions, making it easy to organize and debug."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Rich Set of Operators and Data Types"
        },
        {
          "type": "paragraph",
          "text": "C provides many operators (like +, -, *, /) and data types (like int, char, float) to handle different kinds of tasks."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "5. Low-Level Access (Close to Hardware)"
        },
        {
          "type": "paragraph",
          "text": "You can directly access and manage memory using pointers, which makes it perfect for system-level programming."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "6. Portable"
        },
        {
          "type": "paragraph",
          "text": "You can write a C program on one machine and run it on another with little to no change — thanks to its portability."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "7. Compiled Language"
        },
        {
          "type": "paragraph",
          "text": "C code is compiled, meaning it’s translated into machine code before execution. This makes it faster and more secure."
        },
        {
          "type": "heading",
          "text": "8. Modular and Extendable"
        },
        {
          "type": "paragraph",
          "text": "You can use built-in libraries or create your own functions to reuse code, which saves time and effort."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Applications of C Language"
        },
        {
          "type": "paragraph",
          "text": "C might be old, but it’s still used in many critical areas even today. Here’s where you’ll find C in action:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Operating Systems"
        },
        {
          "type": "paragraph",
          "text": "Major parts of Windows, UNIX, and Linux are written in C."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Embedded Systems"
        },
        {
          "type": "paragraph",
          "text": "Devices like washing machines, microwaves, and digital cameras often run code written in C."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Gaming and Graphics"
        },
        {
          "type": "paragraph",
          "text": "C is used in game engines and graphics drivers where speed is essential."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Compilers and Interpreters"
        },
        {
          "type": "paragraph",
          "text": "Many programming language compilers (like for Python, Java) are themselves written in C."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "5. Mobile and Desktop Applications"
        },
        {
          "type": "paragraph",
          "text": "Some Android system components and desktop tools are built using C."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "6. IoT Devices and Robotics"
        },
        {
          "type": "paragraph",
          "text": "In IoT and robotics, C is often used to control sensors, motors, and communication modules."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "7. Scientific and Engineering Applications"
        },
        {
          "type": "paragraph",
          "text": "Programs that require high-speed mathematical calculations often rely on C."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "8. Scientific and Engineering Applications"
        },
        {
          "type": "paragraph",
          "text": "Most schools and colleges use C to introduce programming because it teaches the basics clearly."
        }
      ]
    },
    {
      "title": "Structure of C Program",
      "description": "Every C program follows a basic structure made up of different sections. Understanding this structure helps you write clean and error-free programs.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "Basic Structure of a C Program"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>    // 1. Preprocessor Directive \n// 2. Global Variable Declaration (optional) \nint main() {       // 3. Main Function \n// 4. Variable Declarations \n// 5. Executable Statements \n return 0;         // 6. Return Statement \n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Preprocessor Directives"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>"
        },
        {
          "type": "paragraph",
          "text": "These lines start with # and tell the compiler to include libraries or perform specific tasks before compilation. For example, #include <stdio.h> is used for input/output functions like printf() and scanf()."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Global Variable Declaration (Optional)"
        },
        {
          "type": "paragraph",
          "text": "You can declare variables or functions outside the main() function if you want to use them throughout the program."
        },
        {
          "type": "textarea",
          "text": "int count = 0; //  global variable"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Main Function"
        },
        {
          "type": "textarea",
          "text": "int main() { \n // Your code here \n return 0; \n}"
        },
        {
          "type": "paragraph",
          "text": "Every C program must have a main() function. This is where program execution starts."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Variable Declarations"
        },
        {
          "type": "textarea",
          "text": "int a, b;"
        },
        {
          "type": "paragraph",
          "text": "Before using any variable, you must declare it. You tell the compiler what type of data the variable will store, (e.g., int for integers, char for characters, or float for decimal numbers.)"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "5. Executable Statements"
        },
        {
          "type": "textarea",
          "text": "a = 5; \nb = 10; \nprintf(\"Sum: %d\", a + b);"
        },
        {
          "type": "paragraph",
          "text": "These lines do the actual work like performing calculations, taking inputs, and printing outputs."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "6. Return Statement"
        },
        {
          "type": "textarea",
          "text": "return 0;"
        },
        {
          "type": "paragraph",
          "text": "This marks the end of the main() functions and return a value to the operating system. Returning 0; usually means the program ran successfully."
        },
        {
          "type": "textarea",
          "text": " #include <stdio.h>\nint main() {\n    int num1 = 10, num2 = 20, sum; \t\t // Variable Declarations \n   sum = num1 + num2;  // Calculating sum\n    printf(\"Sum: %d\", sum); // Printing the result\n    return 0;     // Return statement\n}"
        }
      ]
    },
    {
      "title": "Comments in C Language",
      "description": "Comments are  non-executable lines in a C program that are written to explain the code.",
      "sub_description": " Comments are ignored by the compiler and are only meant for humans (like you or your teammates) to understand the logic, purpose, or function of the code.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "Why use Comments?"
        },
        {
          "type": "list",
          "items": [
            "To describe what the code does.",
            "To enhance the clarity and readability of the program, making it easier to understand, maintain, and update in the future.",
            "To temporarily disable (debug) parts of the code.",
            "To leave notes or reminders for future updates."
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Types of Comments in C"
        },
        {
          "type": "paragraph",
          "text": "C supports two types of comments:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Single-Line Comments"
        },
        {
          "type": "paragraph",
          "text": "Starts with // . Anything after // on the same line is treated as a comment."
        },
        {
          "type": "textarea",
          "text": "# include <stdio.h>\n int main() {\n // This is a single-line comment\n   printf(\"Hello, World!\\n\", a); //Prints a message \n   return 0;\n }"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Multi-Line Comments"
        },
        {
          "type": "paragraph",
          "text": "Starts with /* and end with */. Can span across multiple lines."
        },
        {
          "type": "textarea",
          "text": "/* This is a multi-line comment.\n   It can span multiple lines.\n   Useful for detailed explanations. */\nint b = 10;"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What Comments Cannot Do:"
        },
        {
          "type": "paragraph",
          "text": "They cannot be nested. Example:"
        },
        {
          "type": "textarea",
          "text": "/* This is a comment \n \t\t/* This is a nested comment */ \n*/"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Tips for Writing Good Comments:"
        },
        {
          "type": "list",
          "items": [
            "Be clear and concise.",
            "Don't repeat what the code already says.",
            "Use comments to explain why something is done, not just what is done.",
            "Keep them updated if the code changes."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Real-world Example"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n int main() {\n    int marks; // Ask the user to enter marks \n printf(\"Enter your marks:\"); \n scanf(\"%d\", &marks); // Check if the student passed \n if(marks >= 40) { \n print(\"You passed!\"); \n} \n else{ \n print(\"You failed\"); \n}  return 0;\n }"
        }
      ]
    },
    {
      "title": "Compiling and Executing a C Program",
      "description": "When you write a program in C, it's written in a human-readable format.Before the computers can run it, the code must be translated into machine code.",
      "sub_description": "This is done through a process called Compilation. After compilation, the code is executed (run) on your computer.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "Steps to Compile and Execute a C Program"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Step1 : Write the Code"
        },
        {
          "type": "paragraph",
          "text": "You first write your C program using a text editor and save it with a .c extension."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n int main() {\n    printf(\"Hello, World!\\n\"); \n    return 0; \n }"
        },
        {
          "type": "paragraph",
          "text": "Save the file as hello.c."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Step 2: Compile the Code"
        },
        {
          "type": "paragraph",
          "text": "Use a C compiler (like GCC) to compile the code."
        },
        {
          "type": "paragraph",
          "text": "Command (in terminal/command prompt):"
        },
        {
          "type": "textarea",
          "text": "gcc hello.c -o hello"
        },
        {
          "type": "list",
          "items": [
            "gcc -> GNU c Compiler",
            "hello.c -> Source code file",
            "-o hello -> Output file (name of executable)"
          ]
        },
        {
          "type": "paragraph",
          "text": "If there are no errors, this creates an executable file named hello (or hello.exe on Windows)."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Step 3: Execute the Program"
        },
        {
          "type": "paragraph",
          "text": "Run the compiled program using the following command:"
        },
        {
          "type": "paragraph",
          "text": "On <b>Windows:</b>"
        },
        {
          "type": "textarea",
          "text": "hello.exe"
        },
        {
          "type": "paragraph",
          "text": "On <b>Linux/macOS:</b>"
        },
        {
          "type": "textarea",
          "text": "./hello"
        },
        {
          "type": "paragraph",
          "text": "You should see the output:"
        },
        {
          "type": "textarea",
          "text": "Hello, World!"
        }
      ]
    }
  ],
  " Basic Syntax, Variables & Data Types": [
    {
      "title": "What is Syntax in C?",
      "description": "Syntax is the collection of rules that determine the correct structure and format of C program.",
      "sub_description": "Just like grammar in a language, <b>C syntax ensures that the computer can correctly interpret and execute your code.</b>.",
      "additional_info": "If you break these rules, the compiler will show syntax errors and the program won't run.",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "Key C Syntax Rules"
        },
        {
          "type": "paragraph",
          "text": "Here are some basic but essential C syntax rules every programmer should know:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Every Statement Ends with a Semicolon (;)"
        },
        {
          "type": "paragraph",
          "text": "Statements are terminated with a semicolon(;) so the compiler knows where one instruction ends. <b> Example :</b>"
        },
        {
          "type": "textarea",
          "text": "int a = 10; \n printf(\"Value of a: %d\", a);"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. The Program Execution Starts from main() Function"
        },
        {
          "type": "paragraph",
          "text": "It acts as the starting point of the program, and without it, your code won’t run.This is where the execution begins."
        },
        {
          "type": "textarea",
          "text": "int main() { \n \t //code here \n\t return 0; \n }"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Curly Braces Define code blocks{}"
        },
        {
          "type": "list",
          "items": [
            "Used to group multiple statements.",
            "Every function or control structure must have opening { and closing } braces."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Comments Enhance Code Readability"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Single-Line Comments"
        },
        {
          "type": "textarea",
          "text": "// This is a comment."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Multi-Line Comments"
        },
        {
          "type": "textarea",
          "text": "/* This is a \n multi-line comment. */"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "5. Case Sensitivity"
        },
        {
          "type": "paragraph",
          "text": "C is case-sensitive. main, Main, and MAIN are all considered different."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "6. Header Files Must Be Included"
        },
        {
          "type": "paragraph",
          "text": "The #include directive is used to bring in standard libraries, such as stdio.h, so you can use built-in functions like printf() in your program.<b> Example :</b>"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "7. Proper Use of Data Types and Variables"
        },
        {
          "type": "paragraph",
          "text": "You must declare variables with their correct data types before using them.<b> Example :</b>"
        },
        {
          "type": "textarea",
          "text": "int age = 19; \n float salary = 45550.50;"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "8. Indentation and Formatting (Good Practice)"
        },
        {
          "type": "paragraph",
          "text": "Although not mandatory for the compiler, proper indentation improves code readability and helps in debugging."
        }
      ]
    },
    {
      "title": "Keywords and Identifiers",
      "description": "When writing programs, we use words and names to define actions and store data. These words fall into two categories: keywords and identifiers.",
      "sub_description": "Keywords play a fundamental role in programming. Recognizing the difference between them is essential, as they form the foundation of writing any syntactically correct program.",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "1. What are Keywords?"
        },
        {
          "type": "paragraph",
          "text": "Keywords are special reserved terms in a programming language that come with predefined meanings set by the language itself. You cannot use keywords for naming your variables, functions, or any other user-defined elements, as they are already dedicated to performing particular tasks."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why Are Keywords Important?"
        },
        {
          "type": "list",
          "items": [
            "They tell the compiler or interpreter what action to perform.",
            "Each keyword serves a specific role in the structure of the program.",
            "Misusing a keyword will result in syntax errors."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Example in Python"
        },
        {
          "type": "textarea",
          "text": "if = 5   #Invalid: 'if' is a keyword and cannot be used as a variable name."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Common Keywords in Python:"
        },
        {
          "type": "paragraph",
          "text": "Some commonly used Python keywords include:"
        },
        {
          "type": "paragraph",
          "text": "if, else, elif, for, while, break, continue, def, return, import, True, False, None, and, or, not, pass"
        },
        {
          "type": "paragraph",
          "text": "Remember: These words are <b> not case-sensitive </b> in some languages like Python (e.g., if ≠ IF), but <b> best practice is to always use the correct lowercase format.</b>"
        },
        {
          "type": "heading",
          "level": "2",
          "text": "2. What are Identifiers?"
        },
        {
          "type": "paragraph",
          "text": "Identifiers are the names created by the programmer to identify variables, functions, classes, objects, modules, etc.They act as labels that point to different parts of the program."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why Are Identifiers Important?"
        },
        {
          "type": "list",
          "items": [
            "They allow us to store and retrieve values.",
            "Help keep the code organized, readable, and logical.",
            "They are essential for custom naming."
          ]
        },
        {
          "type": "paragraph",
          "text": "<b> Example :</b>"
        },
        {
          "type": "textarea",
          "text": "name = \"Alice\"  # 'name' is an identifier for string value. \n def greet():    # 'greet' is an identifier for a function. \n\t print(\"Hello, \" + name)"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Rules for Writing Identifiers"
        },
        {
          "type": "paragraph",
          "text": "To avoid errors and follow good practices, identifiers must follow these rules:"
        },
        {
          "type": "list",
          "items": [
            "Can contain letters (A–Z, a–z), digits (0–9), and underscores (_)",
            "Must begin with a letter or underscore, not a digit.",
            "Cannot use a keyword as an identifier name.",
            "Case-sensitive: Name and name are treated as different.",
            "Should be meaningful and descriptive for readability."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Valid Identifiers:"
        },
        {
          "type": "paragraph",
          "text": "tudent_name, Age1, total_marks, _privateVar"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Invalid Identifiers:"
        },
        {
          "type": "paragraph",
          "text": "1name (starts with a digit), class (keyword -> reserved word), my name (contains space) "
        },
        {
          "type": "heading",
          "text": "Use in Real Programs"
        },
        {
          "type": "paragraph",
          "text": "When you build a program, you will:"
        },
        {
          "type": "list",
          "items": [
            "Use keywords to control the program flow (e.g., using if, for, or while).",
            "Create identifiers to name your data and actions (e.g., variables like name, functions like calculate())."
          ]
        }
      ]
    },
    {
      "title": "Variables and Constants",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "Introduction"
        },
        {
          "type": "paragraph",
          "text": "In programming, we deal with data that changes or stays the same throughout the execution of a program. To store and manage this data, we use two essential building blocks — variables and constants. These are the containers that help us handle values effectively."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "1. What are Variables?"
        },
        {
          "type": "paragraph",
          "text": "A variable is like a storage spot in your computer’s memory with its own name, where you keep information that might change while the program runs.It’s similar to a box with a label—you can put something in, take it out, or swap it for something new, but the label on the box always stays the same."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why Are Variables Important?"
        },
        {
          "type": "list",
          "items": [
            "They allow programs to store user input, intermediate results, or final output.",
            "Variables make a program dynamic and interactive."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Example of a Variable in Python"
        },
        {
          "type": "textarea",
          "text": "age = 25  # 'age' is a variable storing the value 25 \n print(age)  # Output: 25 \n age = 30  # Changing the value of 'age' \n print(age)  # Output: 30"
        },
        {
          "type": "paragraph",
          "text": "Here:"
        },
        {
          "type": "list",
          "items": [
            "'age' is the variable name.",
            "It first stores the value 25, then it is updated to 30."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Features of Variables: "
        },
        {
          "type": "list",
          "items": [
            "Variables can change throughout the program.",
            "Variable names should be meaningful (e.g., marks, student_name, total_cost).",
            "They store different data types: numbers, text, boolean values, etc."
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "What are Constants?"
        },
        {
          "type": "paragraph",
          "text": "A constant is a value you set once and then leave alone—it stays the same from the start of your program to the very end."
        },
        {
          "type": "paragraph",
          "text": "Constants are useful when you need to use values that should stay unchanged — like tax rates, Pi (π), or fixed configuration settings."
        },
        {
          "type": "heading",
          "level": "4",
          "text": " Example in Python (Using Naming Convention): "
        },
        {
          "type": "textarea",
          "text": "PI = 3.14159\n print(PI)\n # Trying to change PI (Not recommended, though possible in Python)\n PI = 3.14  \t# Should be avoided"
        },
        {
          "type": "paragraph",
          "text": "In Python, constants are not enforced by the language. By convention, we write constants in all capital letters (e.g., PI, RATE) to signal that their value is intended to stay the same."
        },
        {
          "type": "paragraph",
          "text": "In other languages like C or Java, constants are defined using specific keywords like <b> const </b> or <b> final.</b>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": " Rules for Naming Variables and Constants"
        },
        {
          "type": "list",
          "items": [
            "Names must begin with a <b> letter or underscore.</b>",
            "Can contain letters, digits, and underscores.",
            "<b>No spaces or special characters </b> allowed.",
            "<b>Cannot use keywords </b>(e.g., if, while, return).",
            "Constants are usually written in <b> ALL CAPS.</b>"
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Data Types"
        },
        {
          "type": "paragraph",
          "text": "When writing a program, we deal with different kinds of information — like whole numbers, decimal values, letters, or symbols. A data type tells the computer what kind of data we’re storing so it knows how much memory to allocate and how to work with it."
        },
        {
          "type": "paragraph",
          "text": "Think of data types as different shapes of storage boxes: a box for whole numbers won’t work for text, and a box for text won’t work for precise decimal values. Choosing the right type ensures your program runs correctly and efficiently."
        },
        {
          "type": "paragraph",
          "text": "<b>In C programming, the four most commonly used basic data types are int, float, char, and double, each serving a specific purpose for storing different kinds of data.</b>"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "int — Integer Type"
        },
        {
          "type": "paragraph",
          "text": "The int data type is used to store whole numbers, meaning numbers that  do not have  any decimal or fractional part. It supports storing positive, negative numbers and zero."
        },
        {
          "type": "paragraph",
          "text": " In most systems, an int typically uses 4 bytes of memory, allowing it to store values in a range roughly between -2 billion and +2 billion."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int age = 25; \n printf(\"%d\", age);"
        },
        {
          "type": "paragraph",
          "text": "Here, <b>age</b> is an integer variable storing the value <b>25.</b> Integers are perfect for things like counting, indexing, or working with values that can’t be fractional."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "float — Single Precision Floating Point"
        },
        {
          "type": "paragraph",
          "text": "The float data type stores numbers with decimal points but with limited precision (about 6–7 digits after the decimal). It’s ideal for storing values where some decimal accuracy is needed but extreme precision isn’t required.<b>float uses 4 bytes of memory.</b>"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "float price = 99.99;\n printf(\"%.2f\", price);"
        },
        {
          "type": "paragraph",
          "text": "Here,<b>price</b> stores <b>99.99</b> — which is not possible with <b>int</b> since it contains a decimal. Floats are often used for values like prices, averages, or measurements."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "char — Character Type"
        },
        {
          "type": "paragraph",
          "text": "The char data type stores just one character at a time — this can be letter, a number, or even a special symbol. A char uses 1 byte of memory and stores the character’s ASCII value internally."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "char grade = 'A'; \n printf(\"%c\", grade);"
        },
        {
          "type": "paragraph",
          "text": "Here, grade holds the letter A. Note that characters are always enclosed in single quotes. This type is perfect for storing grades, symbols, or any one-letter input."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "double — Double Precision Floating Point"
        },
        {
          "type": "paragraph",
          "text": "The double data type works like a float but can hold decimal numbers with much higher accuracy — roughly 15 to 16 digits after the decimal. This makes it ideal for scientific calculations, financial computations, or any case where precision is important.<b> double typically uses 8 bytes of memory.</b>"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "double pi = 3.1415926535;\n printf(\"%.10lf\", pi);"
        },
        {
          "type": "paragraph",
          "text": "Here, pi is stored with high precision, allowing accurate mathematical results without significant rounding errors."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Format Specifiers in C"
        },
        {
          "type": "paragraph",
          "text": "In C programming, format specifiers are used inside functions like printf() and scanf() to tell the compiler what type of data is being worked with. They act as placeholders that define how a value should be displayed or read."
        },
        {
          "type": "paragraph",
          "text": "Think of them as instructions that guide the compiler in handling different data types such as integers, characters, floating-point numbers, etc"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Commonly Used Format Specifiers"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "1. %d – Integer Number"
        },
        {
          "type": "paragraph",
          "text": "Used to print or read integer values."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int age = 25;\n \t  printf(\"I am %d years old.\\n\", age); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "I am 25 years old."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "2. %c – Character"
        },
        {
          "type": "paragraph",
          "text": "Used to display or read a single character."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t char grade = 'A';\n \t  printf(\"My grade is %c.\\n\", grade); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "My grade is A."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "3. %f – Floating-Point Number"
        },
        {
          "type": "paragraph",
          "text": "Used for decimal values (floats)."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t float price = 99.50;\n \t  printf(\"The price is %f.\\n\", price); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "The price is 99.50"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "4. %lf – Double (Long Float)"
        },
        {
          "type": "paragraph",
          "text": "Used for double-precision floating-point numbers."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t double pi = 3.1415926535;\n \t  printf(\"Value of pi = %lf.\\n\", pi); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "Value of pi is 3.1415926535"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "5. %s – String"
        },
        {
          "type": "paragraph",
          "text": "Used for sequences of characters (words, sentences)."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t char name[] = \"Webcooks\";\n \t  printf(\"Hello,  %s! \\n\", name); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "Hello Webcooks"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "6. %u – Unsigned Integer"
        },
        {
          "type": "paragraph",
          "text": "Used for positive integers only."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t unsigned int items = 300;\n \t  printf(\"We have %u items in stock.\\n\", items); \n \t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "We have 300 items in stock."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "7. %p – Memory Address (Pointer)"
        },
        {
          "type": "paragraph",
          "text": "Displays the memory address of a variable."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int num = 10;\n \t  printf(\"Memory address of num is %p\\n\", &num); \n\t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "Memory address of num is 0x7ffee4a2c6ac."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "8. %o and %x / %X – Octal and Hexadecimal"
        },
        {
          "type": "list",
          "items": [
            "%o → prints value in octal (base 8)",
            "%x → prints value in hexadecimal (base 16, lowercase)",
            "%X → prints value in hexadecimal (uppercase)"
          ]
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int num = 255;\n \t  printf(\"Octal: %o\\n\", num); \n printf(\"Hex (lowercase): %x\\n\", num);\n   printf(\"Hex (uppercase): %X\\n\", num); \n\t  return 0; \n \t }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output"
        },
        {
          "type": "textarea",
          "text": "Octal: 377 \n Hex (lowercase): ff \n Hex (uppercase): FF"
        }
      ]
    }
  ],
  "Operators and Expressions in C": [
    {
      "title": "Operators and Expressions in C",
      "description": "In C , operators are special symbols used to carry out specific operations on variables and values.",
      "sub_description": "They are the building blocks of any program as they help in performing calculations, making decisions, and controlling the flow of execution.",
      "additional_info": "Let’s go through the main categories step by step:",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "1. Arithmetic Operators"
        },
        {
          "type": "paragraph",
          "text": "Arithmetic operators help us do everyday math in programming, such as adding numbers, subtracting values, multiplying, or dividing them."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int a = 20, b = 6;\n printf(\"Addition: %d\\n\", a + b);\n printf(\"Subtraction: %d\\n\", a - b);\n printf(\"Multiplication: %d\\n\", a * b); \n printf(\"Division: %d\\n\", a / b);\n printf(\"Remainder: %d\\n\", a % b);\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. Relational Operators"
        },
        {
          "type": "paragraph",
          "text": "Relational operators are used to compare two values and find out how they are related, such as whether they are equal, not equal, greater, or smaller.They return either true (1) or false (0) depending on the result."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int x = 10, y = 20;\n printf(\"x == y : %d\\n\", x == y);\n printf(\"x != y : %d\\n\", x != y);\n printf(\"x > y  : %d\\n\", x > y); \n printf(\"x < y  : %d\\n\", x < y);\n printf(\"x >= y : %d\\n\", x >= y);\n printf(\"x <= y : %d\\n\", x <= y);\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. Logical Operators"
        },
        {
          "type": "paragraph",
          "text": "Logical operators let us join two or more conditions together and decide the outcome based on them."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int a = 5, b = 10;\n printf(\"a > 0 && b > 0 : %d\\n\", (a > 0 && b > 0));\n printf(\"a > 0 || b < 0 : %d\\n\", (a > 0 || b < 0));\n printf(\"!(a == b)  : %d\\n\", !(a == b));\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4. Assignment and Increment/Decrement Operators"
        },
        {
          "type": "list",
          "items": [
            "The assignment operator (=) is like a tool that places a value inside a variable, so the variable can hold and use that value whenever needed.",
            "Increment (++) increases a variable by 1.",
            "Decrement (--) decreases a variable by 1."
          ]
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int a = 5;\n a + = 3; //same as a = a + 3 \n printf(\"After += : %d\\n\", a);\n  a++;  // post-increment \n printf(\"After a++ : %d\\n\", a);\n --a;  // pre-decrement \n printf(\"After --a : %d\\n\", a);\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "5. Conditional (Ternary) Operator"
        },
        {
          "type": "paragraph",
          "text": "The ternary operator (? :) is a shorthand for if-else.It takes three operands:"
        },
        {
          "type": "textarea",
          "text": "condition ? expression_if_true : expression_if_false;"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int age = 18;\n (age >= 18) ? printf(\"Eligible to Vote\\n\") : printf(\"Not Eligible\\n\");\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "6. Type Conversion and Typecasting"
        },
        {
          "type": "paragraph",
          "text": "In C, type conversion happens in two ways:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(a) Implicit Type Conversion (Type Promotion)"
        },
        {
          "type": "paragraph",
          "text": "The compiler automatically converts smaller data types into larger data types. <b>Example:</b> int → float → double"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t int a = 10;\n float b = 1; //implicit conversion \n printf(\"Value of b: %.2f\\n\", b);\n return 0;\n }"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(b) Explicit Type Conversion (Typecasting)"
        },
        {
          "type": "paragraph",
          "text": "The programmer manually converts one type into another using (datatype)."
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t float num = 10.75;\n int value = (int)num ; //explicit conversion \n printf(\"Value after typecasting: %d\\n\", value);\n return 0;\n }"
        }
      ]
    }
  ],
  "Input and Output in C": [
    {
      "title": "Input and Output in C",
      "description": "In every program, interaction with the user is very important. In C Programming, user interaction is handled through input and output functions.",
      "sub_description": "These functions come from the standard I/O library (stdio.h) and allow us to read information from the user(input) and display results or messages on the screen (output).",
      "additional_info": "Let’s break them down in detail:",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "1. printf() and scanf()"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "printf():"
        },
        {
          "type": "paragraph",
          "text": "In C, the printf() function helps you show information on the screen.It allows you to print messages, numeric values, or neatly formatted results on the screen."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": " int age = 20; \n printf(\"Your age is %d\", age);"
        },
        {
          "type": "paragraph",
          "text": " Here, %d is a format specifier that tells the program to print an integer value."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "scanf():"
        },
        {
          "type": "paragraph",
          "text": "scanf() helps the program read input provided by the user. You can use it to read numbers, characters, or strings."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": " int age; \n printf(\"Enter your age :\"); \n scanf(\"%d\", &age); \n printf(\"You entered: %d\", age); "
        },
        {
          "type": "paragraph",
          "text": "Notice the & symbol—it tells the program to store the input value in the variable age."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "2. Reading Characters and Strings"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "getchar():"
        },
        {
          "type": "paragraph",
          "text": "This function reads a single character from the user."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "char ch; \n printf(\"Enter a character :\"); \n  ch = getchar(); \n printf(\"You entered: %c\", ch); "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "gets():"
        },
        {
          "type": "paragraph",
          "text": "(not recommended in modern C but still studied in basics): This function reads a string (sequence of characters) from the user until the Enter key is pressed."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "char name[20]; \n printf(\"Enter your name :\"); \n  gets(name); \n printf(\"Hello, %s\", name); "
        },
        {
          "type": "paragraph",
          "text": "⚠️ Note: gets() is unsafe because it doesn’t check the size of input. A safer alternative is fgets()."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "3. Writing Output"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "putchar():"
        },
        {
          "type": "paragraph",
          "text": "This function prints a single character on the screen."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "char ch = 'A'; \n  putchar(ch);"
        },
        {
          "type": "paragraph",
          "text": "⚠️ Note: gets() is unsafe because it doesn’t check the size of input. A safer alternative is fgets()."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "puts():"
        },
        {
          "type": "paragraph",
          "text": " This function prints a string on the screen and automatically moves to the next line."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "char message[] = \"Welcome to C programming!\"; \n  puts(message);"
        }
      ]
    }
  ],
  "Control Flow in C ": [
    {
      "title": " Introduction to Control Flow",
      "description": "In any programming language, the statements are usually executed line by line in sequence (top to bottom). But in real-world problems, we often need to make decisions, repeat actions, or jump to another part of the program.",
      "sub_description": "<b>This is the point where Control Flow comes into the picture.</b>",
      "additional_info": "<b>Definition: </b>In C, control flow refers to the way a program decides the order in which its instructions or statements are executed. It allows us to control what to execute, when to execute, and how many times to execute something.",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "Why do we need Control Flow?"
        },
        {
          "type": "list",
          "items": [
            "To make decisions (e.g., if marks ≥ 40 → pass, else → fail)",
            "To repeat actions until a condition is met (e.g., printing 1 to 10)",
            "To skip or stop execution at a certain point."
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Categories of Control Flow Statements in C"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1. Conditional Statements (Decision-Making)"
        },
        {
          "type": "list",
          "items": [
            "Used to execute certain code only if a condition is true.",
            "Examples: if, if-else, nested if, switch-case"
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. Looping Statements (Repetition)"
        },
        {
          "type": "list",
          "items": [
            "Used when you need to execute a block of code certain code multiple times.",
            "Examples: for, while, do-while"
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. Jumping Statements (Changing Flow Forcefully)"
        },
        {
          "type": "list",
          "items": [
            "Used to change the flow of control suddenly.",
            "Examples: break, continue, goto"
          ]
        }
      ]
    },
    {
      "title": "Conditional Statements in C (Decision-Making)",
      "description": "In programming, we often need to make decisions based on certain conditions. For example, a program might need to figure out if a student has passed or failed, or check whether a number is even or odd.",
      "sub_description": " In C, conditional statements  let the program make these decisions by choosing which parts of code to run based on the conditions. This helps the program take different paths, and work more efficiently.",
      "content": [
        {
          "type": "heading",
          "level": "4",
          "text": "Conditional statements in C include:"
        },
        {
          "type": "list",
          "items": [
            "if statement",
            "if-else statement",
            "nested if statement",
            "switch-case statement"
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "1. if Statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The if statement is the most basic decision-making statement in C."
        },
        {
          "type": "paragraph",
          "text": " It checks a condition, if the condition is true, the code inside the  if block runs. If the condition is false, the program just ignores that code and moves on."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "if (condition) { \n \t\t  // code to execute if condition is true \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int age = 20; \n \t\t if (age >= 18) { \n \t\t\t printf(\"You are eligible to vote.\"); \n \t\t } \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "Here, the condition (age >= 18) is true, so the message \"You are eligible to vote.\" will be printed.",
            "If the age was less than 18, nothing would be printed."
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "2. if-else Statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The if-else statement provides two paths:"
        },
        {
          "type": "list",
          "items": [
            "If the condition is true, the if block executes.",
            "If the condition is false, the else block executes."
          ]
        },
        {
          "type": "paragraph",
          "text": "This is useful when we want the program to do one thing if true, and another if false."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "if (condition) { \n \t\t  // code to execute if condition is true \n } else { \n // code to execute if condition is false \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int marks = 35; \n \t\t if (marks >= 40) { \n \t\t\t printf(\"You passed the exams.\"); \n  } else { \n  printf(\"You failed the exam.\");\n \t\t } \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "If marks >= 40, the program prints \"You passed the exam!\"",
            "Otherwise, it prints \"You failed the exam.\""
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "3. Nested if Statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b>A nested if statement means using one if statement inside another. This is useful when you need to check multiple conditions step by step."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "if (condition1) { \n \t if (condition2) { \n \t // code if both condition1 and condition2 are true \n } \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int marks = 85; \n \t\t if (marks >= 40) {  \n\t if (marks >= 75) {\n \t\t printf(\"You passed with distinction!.\"); \n  } else { \n  printf(\"You passed the exam.\");\n \t\t } \n } else { \n\t printf(\"You failed the exam.\"); \n } \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "First, it checks if marks >= 40.",
            "Then, inside it, another condition checks if marks >= 75.",
            "Based on these conditions, the program prints the correct result."
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "4. Switch-case Statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b>The switch-case statement is an alternative to multiple if-else statements. It allows you to test a variable against multiple values (called cases)."
        },
        {
          "type": "list",
          "items": [
            "If a case matches, the corresponding block of code runs.",
            "If no cases match, the default block (if provided) runs."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "switch (variable) { \n \t case value1: \n  // code for value1 \n break; \n \t case value2: // code for value2  \n break; \n ..... \n default: \n \t // code if no cases match \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int day = 3; \n \t\t switch(day) { \n \t\t case 1: \n \t\t\t printf(\"Monday\"); \n \t\t\t break; \n \t\t case 2: \n \t\t\t printf(\"Tuesday\"); \n \t\t\t break; \n \t\t case 3: \n \t\t\t printf(\"Wednesday\"); \n \t\t\t break; \n \t\t case 4: \n \t\t\t printf(\"Thursday\"); \n \t\t\t break; \n \t\t case 5: \n \t\t\t printf(\"Friday\"); \n \t\t\t break; \n \t\t case 6: \n \t\t\t printf(\"Saturday\"); \n \t\t\t break; \n \t\t case 7: \n \t\t\t printf(\"Sunday\"); \n \t\t\t break; \n \t\t default: \n \t\t\t printf(\"Invalid day number\"); \n \t\t} \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "If day = 3, the program will print \"Wednesday\".",
            "The break statement ensures the program exits the switch after executing the matched case.",
            "If the day is not between 1 and 7, the default block executes."
          ]
        }
      ]
    },
    {
      "title": "Looping Statements (Repetition) in C",
      "description": "<b>Definition: </b>Looping statements in C are used when we need to perform a task repeatedly until a specific condition is satisfied. Rather than repeating the same code again and again, loops let us write the code once and run it as many times as needed.",
      "sub_description": "<b> In simple words:</b> 👉 Looping helps in reducing code redundancy, improving readability, and handling repetitive tasks efficiently.",
      "additional_info": "For example, if you want to print numbers from 1 to 100, instead of writing 100 printf() statements, you can use a loop that runs 100 times.",
      "content": [
        {
          "type": "heading",
          "level": "4",
          "text": "Types of Looping Statements"
        },
        {
          "type": "paragraph",
          "text": "C provides three main looping statements:"
        },
        {
          "type": "list",
          "items": [
            "for loop",
            "while loop",
            "do-while loop"
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "1. for Loop"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The for loop is helpful when we already know how many times a  set of instructions should run. It allows us to repeat  a task a specific number of times in a simple and structured way."
        },
        {
          "type": "paragraph",
          "text": "It is widely used because all loop control statements (initialization, condition, increment/decrement) are written in one line, making it compact."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "for(initialization; condition; update) { \n \t\t  // code to be executed \n }"
        },
        {
          "type": "list",
          "items": [
            "<b> initialization → </b> Sets the loops starting value.",
            "<b> condition → </b> keeps the loop running while true.",
            "<b> update → </b> Changes the loop variable after every iteration."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : Display numbers from 1 to 5"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t for(int i = 1; i <= 5; i++) { \n \t\t\t printf(\"%d\\n\", i); \n \t\t } \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "i=1 (start)",
            "i<=5 (condition)",
            "i++ (increment after each iteration)"
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": "2. while Loop"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The while loop is useful when the exact number of iterations is not known beforehand. It keeps executing until the given condition turns false."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "while(condition) { \n \t\t  // code to be executed \n }"
        },
        {
          "type": "list",
          "items": [
            "condition is checked before executing the loop body.",
            "If the condition is false initially, the loop will not execute even once."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : Print numbers from 1 to 5"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int i = 1; while(int i <= 5) { \n \t\t\t printf(\"%d\\n\", i); \n  i++; \n \t\t } \n return 0; \n }"
        },
        {
          "type": "heading",
          "level": "2",
          "text": "3. do-while Loop"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: A do-while loop is like a while loop, but with one special feature—the code inside the loop is guaranteed to run once before the condition is checked. No matter if the condition is false, the loop body still runs one time.</b> "
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "do { \n \t\t  // code to be executed \n }\n while(condition);"
        },
        {
          "type": "list",
          "items": [
            "Here, the loop body runs first, then the condition is checked."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : Print numbers from 1 to 5"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h> \n int main() { \n \t\t int i = 1; \n \t\t do { \n \t\t\t printf(\"%d\\n\", i); \n \t\t\t i++; \n \t\t} while(i <= 5); \n return 0; \n }"
        },
        {
          "type": "list",
          "items": [
            "Use a for loop when the number of iterations is fixed.",
            "Use a while loop when iterations depend on a condition.",
            "Use do-while loop when you want the code to run at least once."
          ]
        }
      ]
    },
    {
      "title": "Jumping Statements in C (Changing Flow Forcefully)",
      "description": "<b>Definition: </b> Jumping statements in C are control flow statements that let you change the normal order in which a program runs.",
      "sub_description": " Unlike conditional or looping statements that follow a structured flow, jumping statements let you forcefully change the flow of execution by skipping certain parts of code, exiting loops, or transferring control to another part of the program.",
      "content": [
        {
          "type": "heading",
          "level": "5",
          "text": "They are extremely useful in situations where you want to: "
        },
        {
          "type": "paragraph",
          "text": "They are very useful in cases where you may need to: "
        },
        {
          "type": "list",
          "items": [
            "Exit a loop before it finishes.",
            "Skip specific iterations of a loop.",
            "Transfer control to a labeled part of the code."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "In C, the major jumping statements are: "
        },
        {
          "type": "list",
          "items": [
            "break",
            "continue",
            "goto"
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1. break statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The break statement is used to instantly stop the nearest loop (for, while, do-while) or exit from a switch-case block. When the program encounters a break, it jumps directly to the statement that comes right after the loop or switch-case."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "break;"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: Using break in a Loop"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\nint main() {\n\tfor(int i = 1; i <= 5; i++) {\n\t\tif(i == 3) {\n\t\t\tprintf(\"Breaking at i = %d\\n\", i);\n\t\t\tbreak;  // loop terminates here\n\t\t}\n\t\tprintf(\"%d\\n\", i);\n\t}\n\treturn 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Use Case : "
        },
        {
          "type": "paragraph",
          "text": "<b> Stop searching once the required item is found, or terminate a loop early when a condition is met. </b>"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. continue statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The continue statement in a loop skips the remaining statements of the current iteration and directly starts the next iteration. Unlike break, it does not end the loop—it only moves to the next cycle."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "continue;"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: Using continue in a Loop"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\nint main() {\n\tfor(int i = 1; i <= 5; i++) {\n\t\tif(i == 3) {\n\t\t\tcontinue;  // skips printing 3\n\t\t}\n\t\tprintf(\"%d\\n\", i);\n\t}\n\treturn 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Use Case : "
        },
        {
          "type": "paragraph",
          "text": "<b> Skip unwanted iterations, such as skipping even numbers or ignoring invalid inputs. </b>"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. goto statement"
        },
        {
          "type": "paragraph",
          "text": "<b>Definition: </b> The goto statement is used to transfer control unconditionally to a labeled statement within the same function. It provides a way to jump from one part of the program to another."
        },
        {
          "type": "paragraph",
          "text": "⚠️ Note: Although powerful, goto is generally discouraged because it makes the code less readable and harder to debug. However, in certain cases (like breaking out of nested loops), it can be useful."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "goto label;\n...\nlabel:\n    // code to execute"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: Using continue in a Loop"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\nint main() {\n\tfor(int i = 1; i <= 5; i++) {\n\t\tif(i == 3) {\n\t\t\tcontinue;  // skips printing 3\n\t\t}\n\t\tprintf(\"%d\\n\", i);\n\t}\n\treturn 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Use Case : "
        },
        {
          "type": "paragraph",
          "text": "<b> Jumping out of deeply nested loops or handling exceptional conditions. </b>"
        }
      ]
    }
  ],
  "Arrays and Strings": [
    {
      "title": "Introduction to Arrays",
      "description": "When working with programming, we often deal with large amounts of related data. For example, suppose you are building a program to store and process the marks of 100 students. If you try to declare 100 separate variables like this:",
      "sub_description": "<b>int m1, m2, m3, …, m100; </b>",
      "additional_info": "it would be extremely tedious, confusing, and difficult to manage.",
      "content": [
        {
          "type": "heading",
          "level": "5",
          "text": "This is where arrays come in."
        },
        {
          "type": "paragraph",
          "text": " An array is a collection of elements of the same data type, stored in contiguous (side-by-side) memory locations. Instead of creating multiple variables, you can group similar data under a single name and access each element using its index (position)."
        },
        {
          "type": "heading",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int marks[5];"
        },
        {
          "type": "paragraph",
          "text": "Here, we are creating an array named marks that can hold 5 integer values. Each value can be accessed by its index:"
        },
        {
          "type": "list",
          "items": [
            "marks[0] → 1st element",
            "marks[1] → 2nd element",
            "....",
            "marks[4] → 5th element"
          ]
        },
        {
          "type": "paragraph",
          "text": "This makes programming simpler, structured, and easier to manage."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Types of Arrays"
        },
        {
          "type": "paragraph",
          "text": "Arrays can be of different dimensions:"
        },
        {
          "type": "paragraph",
          "text": "<b> 1. One-Dimensional (1D) Arrays – </b> Like a straight line (list)."
        },
        {
          "type": "paragraph",
          "text": "<b> 2. Two-Dimensional (2D) Arrays – </b> Like a table with rows and columns."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "One-Dimensional Arrays (1D Arrays)"
        },
        {
          "type": "paragraph",
          "text": "A 1D array is the simplest form of an array. It can be imagined as a list of elements arranged one after another in memory."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Declaration of 1D Array"
        },
        {
          "type": "textarea",
          "text": "data_type array_name[size];"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int marks[5];"
        },
        {
          "type": "paragraph",
          "text": "This creates an array named marks that can store 5 integers."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Initialization of 1D Array"
        },
        {
          "type": "paragraph",
          "text": "Arrays can be initialized at the time of declaration."
        },
        {
          "type": "textarea",
          "text": "int marks[5] = {90, 85, 78, 92, 88};"
        },
        {
          "type": "paragraph",
          "text": "This creates an array with 5 elements where:"
        },
        {
          "type": "list",
          "items": [
            "marks[0] = 90",
            "marks[1] = 85",
            "marks[2] = 78",
            "marks[3] = 92",
            "marks[4] = 88"
          ]
        },
        {
          "type": "paragraph",
          "text": "<b> Important: </b> Array indexes start from 0 and go up to size – 1."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Accessing Elements of 1D Array"
        },
        {
          "type": "paragraph",
          "text": "You can access any element using its index."
        },
        {
          "type": "textarea",
          "text": "printf(\"%d\", marks[2]);  "
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Operations on 1D Arrays"
        },
        {
          "type": "paragraph",
          "text": "Arrays are very powerful because we can perform different operations on them."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Traversal (Visiting Each Element)"
        },
        {
          "type": "paragraph",
          "text": "We often use a loop to go through all elements: "
        },
        {
          "type": "textarea",
          "text": "for(int i = 0; i < 5; i++) { printf(\"%d \", marks[i]); }"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Searching (Finding an Element)"
        },
        {
          "type": "paragraph",
          "text": "We can check whether a value exists in the array."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "paragraph",
          "text": "<b>Searching for 92 in marks. </b>"
        },
        {
          "type": "textarea",
          "text": "for(int i = 0; i < 5; i++) { if(marks[i] == 92) { printf(\"92 found at index %d\", i); } }"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Sorting (Arranging Data)"
        },
        {
          "type": "paragraph",
          "text": "Sorting helps arrange elements in ascending or descending order."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "Original array: [90, 85, 78, 92, 88]\nSorted (ascending): [78, 85, 88, 90, 92]"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Updating Values"
        },
        {
          "type": "paragraph",
          "text": "We can modify any element using its index."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "marks[2] = 80;   // changes 78 → 80"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Two-Dimensional Arrays (2D Arrays)"
        },
        {
          "type": "paragraph",
          "text": "A 2D array is an array of arrays. You can think of it as a table (matrix) with rows and columns."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Declaration of 2D Array"
        },
        {
          "type": "textarea",
          "text": "data_type array_name[rows][columns];"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int marks[3][3];"
        },
        {
          "type": "paragraph",
          "text": "This creates a 2D array with 3 rows and 3 columns."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Initialization of 2D Array"
        },
        {
          "type": "textarea",
          "text": "int marks[3][3] = {\n    {85, 90, 78},\n    {88, 92, 81},\n    {75, 80, 85}\n};"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Accessing Elements of 2D Array"
        },
        {
          "type": "paragraph",
          "text": "We use two indexes: <b> [row][column].</b>"
        },
        {
          "type": "textarea",
          "text": "printf(\"%d\", marks[1][2]);  //Output: 81 (2nd row, 3rd column)"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Operations on 2D Arrays"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Traversal (Visiting All Element)"
        },
        {
          "type": "paragraph",
          "text": "We use nested loops to go through all rows and columns."
        },
        {
          "type": "textarea",
          "text": "for(int i = 0; i < 3; i++) {\n    for(int j = 0; j < 3; j++) {\n        printf(\"%d \", marks[i][j]);\n    }\n    printf(\"\\n\");\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Row-wise Operations"
        },
        {
          "type": "paragraph",
          "text": "We can calculate the sum/average of each row."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "paragraph",
          "text": "<b>Total marks of each student.</b>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. Column-wise Operations"
        },
        {
          "type": "paragraph",
          "text": "We can calculate the sum/average of each column."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "paragraph",
          "text": "<b>Average marks of each student.</b>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Matrix Operations"
        },
        {
          "type": "paragraph",
          "text": "2D arrays can be used in mathematics for:"
        },
        {
          "type": "list",
          "items": [
            "Addition of two matrices",
            "Subtraction of two matrices",
            "Multiplication of two matrices"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example (Matrix Addition):"
        },
        {
          "type": "textarea",
          "text": "int A[2][2] = {{1, 2}, {3, 4}};\nint B[2][2] = {{5, 6}, {7, 8}};\nint C[2][2];\nfor(int i = 0; i < 2; i++) {\n    for(int j = 0; j < 2; j++) {\n        C[i][j] = A[i][j] + B[i][j];\n    }\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Key Points to Remember"
        },
        {
          "type": "list",
          "items": [
            "Arrays store multiple values of the same type under one name.",
            "Indexes start from 0.",
            "1D Arrays → Like a list.",
            "2D Arrays → Like a table.",
            "Useful for tasks like storing student marks, employee salaries, or performing mathematical computations."
          ]
        }
      ]
    },
    {
      "title": "Strings and String Functions in C",
      "description": "In C programming, a string is essentially a sequence of characters stored in contiguous memory locations and terminated by the special character null (\\0).",
      "content": [
        {
          "type": "heading",
          "level": "4",
          "text": "Key Points:"
        },
        {
          "type": "list",
          "items": [
            "Strings are represented using character arrays.",
            "The null character (\\0) is automatically added when you use double quotes (\" \").",
            "Strings can be initialized in two ways:"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example 1 :"
        },
        {
          "type": "textarea",
          "text": "char str1[] = \"Hello\";"
        },
        {
          "type": "list",
          "items": [
            "Here, the size is determined automatically by the compiler.",
            "Memory layout:"
          ]
        },
        {
          "type": "textarea",
          "text": "H   e   l   l   o   \\0"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example 2 :"
        },
        {
          "type": "textarea",
          "text": "char str2[6] = {'H','e','l','l','o','\\0'};"
        },
        {
          "type": "list",
          "items": [
            "In this method, we manually provide characters including \\0."
          ]
        },
        {
          "type": "paragraph",
          "text": "<b>Important:</b> If you forget \\0, the string functions may behave unexpectedly because they rely on it to know where the string ends."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Why Do We Need String Functions?"
        },
        {
          "type": "paragraph",
          "text": "Working with strings involves common operations like: "
        },
        {
          "type": "list",
          "items": [
            "Finding length (How many characters are there?)",
            "Copying one string into another",
            "Comparing two strings (e.g., password checking)",
            "Concatenating two strings (joining words/sentences)",
            "Reversing strings"
          ]
        },
        {
          "type": "paragraph",
          "text": "<b>Writing manual code for each task is repetitive. That’s why C provides string handling functions in the <string.h> library.</b>"
        },
        {
          "type": "heading",
          "level": "2",
          "text": "Important String Functions"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.1 strlen() – Find String Length"
        },
        {
          "type": "paragraph",
          "text": "This function is used to calculate the number of characters in a string (excluding the null character)."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax :"
        },
        {
          "type": "textarea",
          "text": "int strlen(const char *str);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "Takes the string as input.",
            "Returns an integer value (number of characters)."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\nint main() {\n    char word[] = \"Programming\";\n    int length = strlen(word);\n    printf(\"String: %s\\n\", word);\n    printf(\"Length of the string is: %d\\n\", length);\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "String: Programming  \n Length of the string is: 11"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "How it works internally: "
        },
        {
          "type": "list",
          "items": [
            "<b> strlen() </b> starts from the first character and counts until it finds \\0.",
            "<b> \"Programming\" </b> has 11 characters before \\0."
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.2 strcpy() – Copy One String into Another"
        },
        {
          "type": "paragraph",
          "text": "This function copies the content of the source string into the destination string."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax :"
        },
        {
          "type": "textarea",
          "text": "char *strcpy(char *destination, const char *source);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "destination must have enough memory allocated to hold the source string.",
            "The function automatically adds the null character at the end."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\nint main() {\n    char source[] = \"WebCooks LMS\";\n    char destination[50];  // Ensure it is large enough\n    strcpy(destination, source);\n    printf(\"Source String: %s\\n\", source);\n    printf(\"Destination String after copy: %s\\n\", destination);\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "Source String: WebCooks LMS \n Destination String after copy: WebCooks LMS"
        },
        {
          "type": "paragraph",
          "text": "<b> Note: If the destination array is smaller than the source string, it can cause memory corruption (buffer overflow). </b>"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.3 strcmp() – Compare Two Strings"
        },
        {
          "type": "paragraph",
          "text": "This function compares two strings character by character."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax :"
        },
        {
          "type": "textarea",
          "text": "int strcmp(const char *str1, const char *str2);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Return Values : "
        },
        {
          "type": "list",
          "items": [
            "0 → Both strings are equal ",
            "<0 → str1 is smaller than str2",
            ">0 → str1 is greater than str2"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\nint main() {\n    char str1[] = \"Apple\";\n    char str2[] = \"Banana\";\n    int result = strcmp(str1, str2);\n    if (result == 0)\n        printf(\"Both strings are equal.\\n\");\n    else if (result > 0)\n        printf(\"str1 is greater than str2.\\n\");\n    else\n        printf(\"str1 is smaller than str2.\\n\");\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "str1 is smaller than str2."
        },
        {
          "type": "heading",
          "level": "5",
          "text": " Explanation: "
        },
        {
          "type": "paragraph",
          "text": "<b>\"Apple\"</b> comes before <b> \"Banana\"</b> in dictionary order (ASCII comparison), so it is considered smaller."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.4 strcat() – Concatenate (Join) Strings"
        },
        {
          "type": "paragraph",
          "text": "This function appends the second string to the end of the first string."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax :"
        },
        {
          "type": "textarea",
          "text": "char *strcat(char *destination, const char *source);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Explanation: "
        },
        {
          "type": "list",
          "items": [
            "destination must have enough space to hold the final combined string.",
            "The null character is automatically placed at the end. "
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\nint main() {\n    char str1[50] = \"Hello, \";\n    char str2[] = \"World!\";\n    strcat(str1, str2);\n    printf(\"Concatenated String: %s\\n\", str1);\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "Concatenated String: Hello, World!"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.5 strrev() – Reverse a String (Compiler-Specific)"
        },
        {
          "type": "paragraph",
          "text": "The strrev() function reverses the order of characters in a string."
        },
        {
          "type": "paragraph",
          "text": "<b> This function is not part of the standard C library and may not work in all compilers (e.g., GCC doesn’t support it). </b>"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\nint main() {\n    char str[50] = \"WebCooks\";\n    printf(\"Original String: %s\\n\", str);\n    printf(\"Reversed String: %s\\n\", strrev(str));\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "Original String: WebCooks \n Reversed String: skooCbeW"
        },
        {
          "type": "paragraph",
          "text": "<b> If your compiler doesn’t support strrev(), you can write a custom function using loops. </b>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Real-Life Examples of String Functions"
        },
        {
          "type": "list",
          "items": [
            "strlen() → Count characters in a username.",
            "strcpy() → Save a copy of a student’s name in a database.",
            "strcmp() → Check if the entered password matches the stored one.",
            "strcat() → Join first name and last name into a full name.",
            "strrev() → Used in palindrome checking (madam reversed is also madam)."
          ]
        }
      ]
    }
  ],
  "Functions and Recursion in C": [
    {
      "title": "Introduction to Functions ",
      "description": "Imagine your daily routine without tea. Every morning you would need to do this process for yourself: boiling water, adding sugar, putting tea leaves, boiling milk, and mixing everything. Now, imagine you had to explain this process to someone, step by step, every time. Totally exhausting, isn't it? ",
      "sub_description": "What if instead of going through the process each time, you just said \"Make tea\" and the person already knew the steps? How much time and effort that would save you! Just like that in C programming, functions work.",
      "additional_info": " Instead of writing the same code multiple times, you can write it once inside a function and then just call it whenever you need it.",
      "content": [
        {
          "type": "paragraph",
          "text": "<b> Functions help you: </b>"
        },
        {
          "type": "list",
          "items": [
            "Break down your program into manageable pieces.",
            "Prevent repetition of the code.",
            "Keep programs readable and manageable."
          ]
        },
        {
          "type": "paragraph",
          "text": "So, let's discuss recursion. Recursion is a bit of a trick. It says that a function can call itself to solve a problem. At the beginning, it may sound confusing, but it is a very powerful concept. "
        },
        {
          "type": "paragraph",
          "text": "In real programming, recursion is used for solving various problems like calculating factorials, generating Fibonacci numbers, solving puzzles, or dealing with trees and graphs."
        },
        {
          "type": "paragraph",
          "text": "After this module, you will get to know:"
        },
        {
          "type": "list",
          "items": [
            "The methods to declare, define, and call functions",
            "The Different ways of passing data to functions (Call by Value & Call by Reference)",
            "The difference between Local and Global variables (scope of variables)",
            "The principle of recursion and the places where it can be applied."
          ]
        },
        {
          "type": "paragraph",
          "text": "Start with step-by-step. "
        }
      ]
    },
    {
      "title": "Function Declaration, Definition, and Calling",
      "description": "A function in C is like a small machine inside your program. You feed it an input (parameters), it performs the specified operation, and the output (return value) may be given back to you.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": " Function Declaration (Prototype)"
        },
        {
          "type": "paragraph",
          "text": "You have to declare a function in C before you use it. This is the way of telling the compiler: "
        },
        {
          "type": "paragraph",
          "text": "“Hey, a function is coming later in the program, and this is how it looks.”"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax:"
        },
        {
          "type": "textarea",
          "text": "return_type function_name(parameter_list);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": " Example:"
        },
        {
          "type": "textarea",
          "text": "int add(int x, int y);"
        },
        {
          "type": "paragraph",
          "text": "Here, "
        },
        {
          "type": "list",
          "items": [
            "The function name is add.",
            "It takes two integers as input.",
            "It will return an integer."
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": " Function Definition"
        },
        {
          "type": "paragraph",
          "text": "The definition is the place where you provide the function with its working logic."
        },
        {
          "type": "textarea",
          "text": "int add(int x, int y) {\n    return x + y;\n}"
        },
        {
          "type": "paragraph",
          "text": "This function puts together the two numbers given as input and returns the result."
        },
        {
          "type": "heading",
          "level": "3",
          "text": " Function Calling"
        },
        {
          "type": "paragraph",
          "text": "If you have declared and defined the function, you can use it inside main() or another function by calling it."
        },
        {
          "type": "textarea",
          "text": "int main() {\n    int result = add(10, 20);\n    printf(\"Result = %d\\n\", result);\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "The machine, instead of the user, when issuing the command, will thereby be sent to the function add(), which is performed and then returns the result back."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Why Functions are Important? "
        },
        {
          "type": "list",
          "items": [
            "Do not write the same code multiple times.",
            "Split big programs into smaller parts.",
            "Make debugging and testing easier",
            "Help readability and structure."
          ]
        }
      ]
    },
    {
      "title": "Function Parameters: Call by Value and Call by Reference",
      "description": "There are two different ways to send data to a function. We shall explain both methods in simple words.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "Call by Value"
        },
        {
          "type": "paragraph",
          "text": "Here, the copy of the variable is sent to the function. Any changes made inside the function will not affect the original variable."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "void square(int n) {\n    n = n * n;\n    printf(\"Inside function: %d\\n\", n);\n}\nint main() {\n    int a = 5;\n    square(a);\n    printf(\"Outside function: %d\\n\", a);  // still 5\n}"
        },
        {
          "type": "paragraph",
          "text": " It is similar to giving your friend a photocopy of your notebook. They can write or erase things in the copy, but your original notebook remains unchanged."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Call by Reference"
        },
        {
          "type": "paragraph",
          "text": "In this method, instead of a copy, you pass the address of the variable (using pointers). So the function can modify the original value directly. "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "void square(int *n) {\n    *n = (*n) * (*n);\n}\nint main() {\n    int a = 5;\n    square(&a);\n    printf(\"After function: %d\\n\", a);  // prints 25\n}"
        },
        {
          "type": "paragraph",
          "text": "It is like giving your friend the actual notebook. If they make changes, so does the original one."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "When to Use What? "
        },
        {
          "type": "list",
          "items": [
            "Call by Value should be employed if you do not want a function to modify the original data of yours.",
            "Call by Reference is the right choice when you want the function to change the data."
          ]
        }
      ]
    },
    {
      "title": "Function Scope: Local and Global Variables",
      "description": "The scope of a variable shows where in the program one can access that variable.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": " Local Variables "
        },
        {
          "type": "list",
          "items": [
            "Declared inside a function or a block.",
            "They exist only during the function execution.",
            "They are removed when the function ends."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "void show() {\n    int x = 10;  // local variable\n    printf(\"%d\\n\", x);\n}"
        },
        {
          "type": "paragraph",
          "text": "You cannot access x outside the function <b> show(). </b>"
        },
        {
          "type": "paragraph",
          "text": "Local variables are like notes on your rough paper during a lecture. Once the lecture ends, you throw away the rough notes."
        },
        {
          "type": "heading",
          "level": "3",
          "text": " Global Variables "
        },
        {
          "type": "list",
          "items": [
            "Declared outside all functions.",
            "They exist for the entire program.",
            "Any function can access them."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int count = 0;  // global variable\nvoid increase() {\n    count++;\n}\nint main() {\n    increase();\n    printf(\"%d\\n\", count);  // prints 1\n}"
        },
        {
          "type": "paragraph",
          "text": "Global variables are like a notice on the school board – everyone in the school can see and use it."
        },
        {
          "type": "paragraph",
          "text": "Warning: If too many functions change a global variable, it can result in erratic output."
        }
      ]
    },
    {
      "title": "Recursion in C",
      "description": "Recursion is a situation where a function calls itself.",
      "sub_description": "Initially, this might seem odd, but it is very effective for dividing a problem into smaller parts and then solving it.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "How Recursion Works ?"
        },
        {
          "type": "paragraph",
          "text": "Every recursive function consists of these two segments:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Base Case → "
        },
        {
          "type": "paragraph",
          "text": "It is the termination condition. Without it, the function would infinitely keep calling itself."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Recursive Case → "
        },
        {
          "type": "paragraph",
          "text": "The function invokes itself with a smaller input or simpler one."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: Factorial Using Recursion"
        },
        {
          "type": "textarea",
          "text": "int factorial(int n) {\n    if (n == 0)   // base case\n        return 1;\n    else\n        return n * factorial(n - 1);  // recursive case\n}"
        },
        {
          "type": "paragraph",
          "text": "If you call <b> factorial(3): </b>"
        },
        {
          "type": "list",
          "items": [
            "factorial(3) = 3 × factorial(2)",
            "factorial(2) = 2 × factorial(1)",
            "factorial(1) = 1 × factorial(0)",
            "factorial(0) = 1 (base case reached)"
          ]
        },
        {
          "type": "paragraph",
          "text": "So, the answer is 6."
        },
        {
          "type": "heading",
          "level": "4",
          "text": " Where Recursion is Useful ?"
        },
        {
          "type": "list",
          "items": [
            "Mathematical problems (factorial, Fibonacci, GCD)",
            "Sorting algorithms (QuickSort, MergeSort)",
            "Searching in trees and graphs",
            "Puzzles like Tower of Hanoi"
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": " When to Avoid Recursion ?"
        },
        {
          "type": "list",
          "items": [
            "When loops could solve the problem more easily.",
            "The recursion depth is too high (program may crash)."
          ]
        },
        {
          "type": "paragraph",
          "text": "Think of recursion like <b> Russian dolls </b> (nested dolls). You keep opening one after another until you reach the smallest doll – that’s the base case."
        }
      ]
    }
  ],
  "Pointers in C": [
    {
      "title": "Introduction to Pointers",
      "description": "In the C programming language, variables were the main things that allowed us to keep values such as numbers and characters. However, sometimes we need something more powerful, i.e., a way working directly with memory addresses. Pointers are just the things that fulfill this need.",
      "sub_description": "A pointer is a variable that stores the location of another variable. So instead of given (like 10), a pointer shows us the location of the number in memory.",
      "additional_info": "<b>Real-life analogy: </b>Imagine a variable as your home. The house holds the stuff (the value). A pointer is like a Google Maps pin — it doesn’t carry the thing itself but shows you where it is located.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "Declaring and Using Pointers : "
        },
        {
          "type": "textarea",
          "text": "int x = 42;      // normal variable\nint *ptr;        // declare a pointer to int\nptr = &x;        // assign address of x to pointer"
        },
        {
          "type": "list",
          "items": [
            "&x → gives the address of x.",
            "*ptr → accesses the value stored at the address ptr is pointing to (dereferencing)."
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Pointer Arithmetic"
        },
        {
          "type": "paragraph",
          "text": "Pointers manipulators can be used to navigate through the memory."
        },
        {
          "type": "paragraph",
          "text": "<b> Important: </b> Arithmetic only works if the data type size is known."
        },
        {
          "type": "list",
          "items": [
            "<b> Increment (ptr++) </b> → moves one step further to the next element.",
            "<b> Decrement (ptr--) </b> → goes one step back to the previous element.",
            "<b> Addition/Subtraction </b> → allows to move through the memory by multiple elements."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int arr[] = {10, 20, 30, 40};  // initializing array\nint *p = arr;  // pointer to the first element of the array\nprintf(\"First: %d\\n\", *p);  // dereference p to access the first element\nprintf(\"Second: %d\\n\", *(p+1));  // dereference (p+1) to access the second element\nprintf(\"Third: %d\\n\", *(p+2));  // dereference (p+2) to access the third element"
        },
        {
          "type": "paragraph",
          "text": "In this case, (p+1)moves automatically by 4 bytes (size of int)."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Pointers with Arrays and Strings"
        },
        {
          "type": "paragraph",
          "text": "Arrays and pointers are inseparably connected."
        },
        {
          "type": "list",
          "items": [
            "The name of the array (arr) is similar to a pointer to the first element.",
            "Getting arr[i] is equal to *(arr + i)."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example with arrays: "
        },
        {
          "type": "textarea",
          "text": "int numbers[3] = {5, 10, 15};  // initializing array\nint *ptr = numbers;  // pointer to the first element of the array\nfor(int i = 0; i < 3; i++) {  // loop through the array\n    printf(\"%d \", *(ptr + i));  // dereference (ptr + i) to access each element\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "5 10 15"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Strings and pointers"
        },
        {
          "type": "paragraph",
          "text": "A string is a character array wrapped in \\0. We can easily follow it using pointers, we can easily traverse it."
        },
        {
          "type": "textarea",
          "text": "char str[] = \"C Language\";  // initializing string\nchar *p = str;  // pointer to the first character of the string\nwhile(*p != '\\0') {  // loop until the null terminator is reached\n    printf(\"%c \", *p);  // dereference p to print the character\n    p++;  // move the pointer to the next character\n}"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Output: "
        },
        {
          "type": "textarea",
          "text": "C   L   a   n   g   u   a   g   e"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Pointers with Functions"
        },
        {
          "type": "paragraph",
          "text": "By default, C copies the values when passing parameters to functions. However, the use of pointers makes the call by reference possible which allows the direct modification of variables."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example with arrays: "
        },
        {
          "type": "textarea",
          "text": "void swap(int *a, int *b) {  // function to swap values\n    int temp = *a;  // store the value of a in temp\n    *a = *b;  // assign the value of b to a\n    *b = temp;  // assign the value of temp (old value of a) to b\n}"
        },
        {
          "type": "paragraph",
          "text": "Called with:"
        },
        {
          "type": "textarea",
          "text": "swap(&x, &y);"
        },
        {
          "type": "paragraph",
          "text": "This changes the original values instead of copies only."
        }
      ]
    },
    {
      "title": "Advanced Pointer Concepts",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "1. Null Pointers"
        },
        {
          "type": "paragraph",
          "text": "Those are pointers which are not pointing to anywhere."
        },
        {
          "type": "textarea",
          "text": "int *p = NULL;"
        },
        {
          "type": "paragraph",
          "text": "In order to be safe (prevent the access to random memory locations), it is used."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. Dangling Pointers"
        },
        {
          "type": "paragraph",
          "text": "A pointer that references memory that has been deallocated or is no longer in scope. For example, producing the location of a local variable in a function as a function's return value."
        },
        {
          "type": "paragraph",
          "text": "After freeing, pointers should be set to NULL all the time."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. Void Pointers"
        },
        {
          "type": "paragraph",
          "text": "A pointer that can take the address of any data type is called a void pointer."
        },
        {
          "type": "textarea",
          "text": "void *ptr;  // declare a void pointer\nint x = 10;  // initialize an integer\nptr = &x;  // assign address of x to void pointer\nprintf(\"%d\", *(int*)ptr);  // typecast the void pointer to int* before dereferencing to print the value of x"
        },
        {
          "type": "paragraph",
          "text": "It is very convenient for <b> generic programming. </b>"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4. Pointer to Pointer (Double Pointer) "
        },
        {
          "type": "paragraph",
          "text": "Sometimes, we even want a pointer that points to the location of another pointer."
        },
        {
          "type": "textarea",
          "text": "int x = 5;  // initialize integer x\nint *p = &x;  // pointer to x\nint **pp = &p;  // pointer to pointer p\nprintf(\"%d\", **pp);  // dereference pp twice to access the value of x, which is 5"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "5. Dynamic Memory Allocation (Intro)"
        },
        {
          "type": "paragraph",
          "text": "The concept of dynamic memory through pointers is available with: "
        },
        {
          "type": "list",
          "items": [
            "malloc() – allocates memory",
            "calloc() – allocates and initializes memory",
            "free() – releases memory"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <stdlib.h>\nint main() {\n    int *ptr = (int*) malloc(3 * sizeof(int));  // allocate memory for 3 integers\n    ptr[0] = 10; ptr[1] = 20; ptr[2] = 30;  // assign values to the allocated memory\n    for(int i = 0; i < 3; i++) {  // loop through and print the values\n        printf(\"%d \", ptr[i]);\n    }\n    free(ptr);  // release the allocated memory\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Common Mistakes with Pointers"
        },
        {
          "type": "list",
          "items": [
            "<b> Uninitialized pointers </b> (pointing to garbage memory).",
            "<b> Dereferencing NULL pointers </b> (crash).",
            "<b> Memory leaks </b> (forgetting to free() dynamically allocated memory).",
            "<b> Dangling pointers </b> (using pointers after free)."
          ]
        }
      ]
    }
  ],
  "Structures, Unions, and Enums": [
    {
      "title": "Introduction to Structures, Unions, and Enums",
      "description": "When building real-world software in C, you usually encounter various data types — numbers, characters, strings, and so on. But most of the time, these different data elements are logically linked and have to be combined into one group.",
      "content": [
        {
          "type": "heading",
          "level": "5",
          "text": "For example: "
        },
        {
          "type": "list",
          "items": [
            "A student is  identified by his name, roll number, and marks.",
            "An employee is described with an ID, salary, and department.",
            "A book consists of  a title, author, and price."
          ]
        },
        {
          "type": "paragraph",
          "text": "To represent and manage such logically connected data in an organized way, C offers you three features — Structures, Unions, and Enums. Let’s delve into these features."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1. Structures in C"
        },
        {
          "type": "paragraph",
          "text": "A Structure in C is a user-defined composite data type that combines  variables of different data types  into one variable. Simply, it’s a method of defining your own data type that can store a set of related data."
        },
        {
          "type": "paragraph",
          "text": "Unlike arrays (which can hold multiple values of the same type), structures are capable of storing multiple types i.e. one can store integers, floats, characters, or even arrays all together."
        },
        {
          "type": "paragraph",
          "text": "This lets you model an entity from the real world more accurately by including all its properties in one logical unit."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "For example: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n\nstruct Student {\n    char name[50];\n    int age;\n    float marks;\n};\n\nint main() {\n    struct Student student1;\n    // Initialize the student\n    student1.age = 20;\n    student1.marks = 90.5;\n    snprintf(student1.name, sizeof(student1.name), \"John Doe\");\n\n    // Print student details\n    printf(\"Name: %s\\n\", student1.name);\n    printf(\"Age: %d\\n\", student1.age);\n    printf(\"Marks: %.2f\\n\", student1.marks);\n\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "Here: "
        },
        {
          "type": "list",
          "items": [
            "struct → a keyword that specifies the creation of a new structure definition.",
            "Student → the structure’s name.",
            "name, age, and marks → members of the structure(different data types grouped together)."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why Use Structures?"
        },
        {
          "type": "list",
          "items": [
            "To hold variables of different data types in one variable/object. ",
            "To help manage and organize large programs by making them modular.",
            "To represent real-world objects like students, employees, or books."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax of a Structure"
        },
        {
          "type": "textarea",
          "text": "struct structure_name {\n    data_type member1;\n    data_type member2;\n    // ...\n};"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example:"
        },
        {
          "type": "textarea",
          "text": "struct Employee {\n    int emp_id;\n    char name[50];\n    float salary;\n};"
        },
        {
          "type": "heading",
          "level": "3",
          "text": " Declaring and Accessing Structure Variables"
        },
        {
          "type": "paragraph",
          "text": "After defining a structure, we can declare its variables as shown below:"
        },
        {
          "type": "textarea",
          "text": "struct Employee e1;  // structure variable"
        },
        {
          "type": "paragraph",
          "text": "To get the value of a member or assign a value to it, you can use the dot (.) operator: "
        },
        {
          "type": "textarea",
          "text": "e1.emp_id = 101;\nstrcpy(e1.name, \"Amit\");\ne1.salary = 45000.75;\nprintf(\"Employee ID: %d\\n\", e1.emp_id);\nprintf(\"Name: %s\\n\", e1.name);\nprintf(\"Salary: %.2f\\n\", e1.salary);"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. Nested Structures "
        },
        {
          "type": "paragraph",
          "text": "A Nested Structure means a structure defined inside another structure. It is used when one complex entity contains another sub-entity."
        },
        {
          "type": "paragraph",
          "text": "For example, a Student may have a name, age, and address.However, the address may be a combination of different parts like city, state, and pincode."
        },
        {
          "type": "paragraph",
          "text": " In such cases, we can define one structure (Address) inside another (Student)."
        },
        {
          "type": "textarea",
          "text": "struct Address {\n    char city[50];\n    int pincode;\n};\n\nstruct Student {\n    char name[50];\n    int age;\n    struct Address addr;  // Nested structure\n};"
        },
        {
          "type": "paragraph",
          "text": "To access nested structure members: "
        },
        {
          "type": "textarea",
          "text": "struct Student s1;\nstrcpy(s1.name, \"Riya\");\ns1.age = 20;\nstrcpy(s1.addr.city, \"Delhi\");\ns1.addr.pincode = 110001;\nprintf(\"City: %s\\n\", s1.addr.city);"
        },
        {
          "type": "paragraph",
          "text": "<b> Use Case: </b> Nested structures allow data to be more organized and have a hierarchical nature — perfect for keeping such details as student records, employee contact information, or publication data of books."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. Structures and Pointers "
        },
        {
          "type": "paragraph",
          "text": "The pointer to a structure is defined as a variable that holds the location of the structure variable in the memory. By using this, you can find the structure members by their addresses in the memory instead of using their names."
        },
        {
          "type": "paragraph",
          "text": "It is very convenient when you want to pass structures to functions because it avoids the making of several copies of large data structures."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax: "
        },
        {
          "type": "textarea",
          "text": "struct structure_name *ptr;"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example:"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\nstruct Student {\n    char name[50];\n    int age;\n    float percentage;\n};\n\nint main() {\n    struct Student s1 = {\"Aman\", 22, 85.7};\n    struct Student *ptr = &s1;\n\n    printf(\"Name: %s\\n\", ptr->name);\n    printf(\"Age: %d\\n\", ptr->age);\n    printf(\"Percentage: %.2f\\n\", ptr->percentage);\n\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "<b> Note: </b>When pointers are used with structures, the members are accessed by the use of the arrow operator (->) rather than the dot operator (.). "
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4. Unions in C"
        },
        {
          "type": "paragraph",
          "text": "A Union in C is a user-defined data type that is almost like a structure but differs in one aspect that all members of a union have the same memory location."
        },
        {
          "type": "paragraph",
          "text": "That is, a union can store only one value at a time, as all members overlap in memory."
        },
        {
          "type": "paragraph",
          "text": " So, a union is a way to store different types of data in the same memory space, but they can not be available at the same time. For this reason, unions are memory efficient — the size of their largest member is used as the size of the union, thus representing all members."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax: "
        },
        {
          "type": "textarea",
          "text": "union union_name {\n    data_type member1;\n    data_type member2;\n    // ...\n};"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "union Data {\n    int i;\n    float f;\n    char str[20];\n};"
        },
        {
          "type": "paragraph",
          "text": "If we assign a value to i and then to f, the second assignment will replace the first because both have the same memory."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example Program: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <string.h>\n\nunion Data {\n    int i;\n    float f;\n    char str[20];\n};\n\nint main() {\n    union Data d1;\n    d1.i = 10;\n    printf(\"Integer: %d\\n\", d1.i);\n    d1.f = 20.5;\n    printf(\"Float: %.2f\\n\", d1.f);\n    strcpy(d1.str, \"Hello\");\n    printf(\"String: %s\\n\", d1.str);\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "<b> Use Case: </b> Unions are helpful when working with data that can change different forms at different times, such as: "
        },
        {
          "type": "list",
          "items": [
            "Storing numeric or string input from a user.",
            "Working with hardware registers.",
            "Representing data packets where only one type of information is valid at a time."
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "5. Enums in C"
        },
        {
          "type": "paragraph",
          "text": "An Enum (short for Enumeration) in C is a user-defined data type that allows you to assign names to a set of integer constants."
        },
        {
          "type": "paragraph",
          "text": "Enums make your code more readable and meaningful by replacing numbers with descriptive names."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Instead of writing: "
        },
        {
          "type": "textarea",
          "text": "int day = 1;  // Hard to understand "
        },
        {
          "type": "heading",
          "level": "5",
          "text": "You can write: "
        },
        {
          "type": "textarea",
          "text": "enum Day { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; "
        },
        {
          "type": "paragraph",
          "text": "Now, using <b> Monday </b> or <b> Tuesday </b> is much clearer than using 1 or 2."
        },
        {
          "type": "paragraph",
          "text": "By default, the compiler assigns integer values starting from 0, but you can manually assign your own values too. "
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax: "
        },
        {
          "type": "textarea",
          "text": "enum enum_name {\n    constant1,\n    constant2,\n    // ...\n};"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "enum Direction { NORTH = 1, EAST, SOUTH, WEST }; "
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example Program: "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n\nenum Level { LOW = 1, MEDIUM, HIGH };\n\nint main() {\n    enum Level alert = HIGH;\n    if (alert == HIGH)\n        printf(\"Alert Level: HIGH\\n\");\n    else\n        printf(\"Normal Level\\n\");\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "<b> Use Case: </b> Enums are used when you have a fixed set of related constant values, such as: "
        },
        {
          "type": "list",
          "items": [
            "Days of the week",
            "Menu options",
            "Error codes",
            "Alert levels or modes "
          ]
        }
      ]
    }
  ],
  "File Handling in C ": [
    {
      "title": "What is File Handling in C?",
      "description": "When we write a C program, the data we create or use exists only while the program is running.",
      "sub_description": "As soon as we stop the program, all that data disappears — because it’s stored temporarily in the computer’s memory (RAM).",
      "additional_info": "But what if we want to save information permanently?",
      "content": [
        {
          "type": "heading",
          "level": "5",
          "text": " For example:"
        },
        {
          "type": "list",
          "items": [
            "A billing system should keep all the bills even after the program closes.",
            "A student management system should store student records for future use.",
            "A banking application must save all transactions."
          ]
        },
        {
          "type": "paragraph",
          "text": "This is where file handling comes in."
        },
        {
          "type": "paragraph",
          "text": "File handling allows us to store data in files on the disk and access it whenever we need, just like saving and opening a document in your computer."
        },
        {
          "type": "paragraph",
          "text": "So, in simple words — "
        },
        {
          "type": "paragraph",
          "text": "File handling helps you make your program remember data even after it stops running."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Types of Files in C"
        },
        {
          "type": "paragraph",
          "text": "C allows us to work with two main types of files: "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Text Files"
        },
        {
          "type": "paragraph",
          "text": "These are normal files that store data in a readable form — meaning, you can open them in Notepad and easily understand the content."
        },
        {
          "type": "paragraph",
          "text": "For Example: "
        },
        {
          "type": "textarea",
          "text": "Name: Riya\nAge: 20\nMarks: 85"
        },
        {
          "type": "paragraph",
          "text": "Each character here is stored using its ASCII value."
        },
        {
          "type": "paragraph",
          "text": "<b> Use Case: <b> Storing things like reports, student data, receipts, or notes — anything that needs to be human-readable."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Binary Files"
        },
        {
          "type": "paragraph",
          "text": "Binary files store data in binary (0s and 1s) format."
        },
        {
          "type": "paragraph",
          "text": " You can’t read them directly because they’re meant for the computer, not humans."
        },
        {
          "type": "paragraph",
          "text": "But they are faster, smaller in size, and more secure than text files."
        },
        {
          "type": "paragraph",
          "text": "<b> Use Case: <b> Storing images, database records, or any large data that doesn’t need to be human-readable."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Steps to Work with Files"
        },
        {
          "type": "paragraph",
          "text": "To use a file in C, we usually follow these four basic steps:"
        },
        {
          "type": "list",
          "items": [
            "Open the file using fopen().",
            "Read or Write data using functions like fprintf(), fscanf(), fgets(), or fputs().",
            "Close the file using fclose().",
            "Optionally, process or update the data as needed."
          ]
        },
        {
          "type": "paragraph",
          "text": "Just like how you open a notebook, write in it, and close it after finishing — we do the same with files in programming."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Opening and Closing Files"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "a. fopen() "
        },
        {
          "type": "paragraph",
          "text": "This function is used to open a file before we start working with it. It needs two things: "
        },
        {
          "type": "list",
          "items": [
            "The file name (like \"data.txt\")",
            "The mode in which we want to open it (like \"r\" for reading or \"w\" for writing)"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "FILE *file;\nfile = fopen(\"data.txt\", \"r\");"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "b. fclose() "
        },
        {
          "type": "paragraph",
          "text": "Once we’re done reading or writing, it’s important to close the file using fclose()."
        },
        {
          "type": "paragraph",
          "text": "It ensures that all data is safely saved and prevents corruption or loss."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "fclose(file);"
        },
        {
          "type": "paragraph",
          "text": "Think of it as closing your notebook after writing, so the pages don’t get damaged."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Reading and Writing Text Files"
        },
        {
          "type": "paragraph",
          "text": "There are several functions to handle reading and writing text data:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "a. fprintf() and fscanf()"
        },
        {
          "type": "paragraph",
          "text": "These are similar to printf() and scanf() but work with files instead of the screen."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example:"
        },
        {
          "type": "textarea",
          "text": "FILE *fptr;\nfptr = fopen(\"student.txt\", \"w\");\nfprintf(fptr, \"Name: Riya\\nAge: 20\\nMarks: 85\");\nfclose(fptr);\n\nfptr = fopen(\"student.txt\", \"r\");\nchar name[20];\nint age, marks;\nfscanf(fptr, \"Name: %s\\nAge: %d\\nMarks: %d\", name, &age, &marks);\nfclose(fptr);"
        },
        {
          "type": "paragraph",
          "text": "Here, fprintf() writes formatted data to the file and fscanf() reads it back."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "b. fputs() and fgets()"
        },
        {
          "type": "paragraph",
          "text": "These functions work with strings or lines of text."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example:"
        },
        {
          "type": "textarea",
          "text": "FILE *fptr;\nchar line[100];\n\n// Writing to file\nfptr = fopen(\"note.txt\", \"w\");\nfputs(\"Learning file handling in C!\", fptr);\nfclose(fptr);\n\n// Reading from file\nfptr = fopen(\"note.txt\", \"r\");\nfgets(line, 100, fptr);\nprintf(\"%s\", line);\nfclose(fptr);"
        },
        {
          "type": "paragraph",
          "text": "Here, fputs() writes one line to a file, and fgets() reads one line from it."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Binary File Handling"
        },
        {
          "type": "paragraph",
          "text": "In binary file handling, data is stored in the same format as it is in memory — which makes it faster and more space-efficient.We use: "
        },
        {
          "type": "list",
          "items": [
            "fwrite() → to write binary data.",
            "fread() → to read binary data."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example:"
        },
        {
          "type": "textarea",
          "text": "FILE *fptr;\nint num = 25;\nfptr = fopen(\"data.bin\", \"wb\"); // 'wb' means write binary\nfwrite(&num, sizeof(num), 1, fptr);\nfclose(fptr);"
        },
        {
          "type": "paragraph",
          "text": "This method is often used for programs that need to store and retrieve structured data (like student records or images)."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Why File Handling Matters?"
        },
        {
          "type": "paragraph",
          "text": "File handling plays a key role in almost every real-world application: "
        },
        {
          "type": "list",
          "items": [
            "It lets us store data permanently.",
            "It helps in reading and updating old records.",
            "It makes programs more practical and user-friendly."
          ]
        },
        {
          "type": "paragraph",
          "text": "Without file handling, your program would “forget” everything once it stops running — making it impossible to build things like: "
        },
        {
          "type": "list",
          "items": [
            "Banking software",
            "Library management systems",
            "Billing or inventory applications",
            "Data logging systems"
          ]
        },
        {
          "type": "paragraph",
          "text": "So, learning file handling is your first step toward building real, data-driven applications in C."
        }
      ]
    }
  ],
  "Dynamic Memory Allocation in C ": [
    {
      "title": "Introduction to Dynamic Memory Allocation",
      "description": "When we write a C program, we often know in advance how much memory we’ll need — for example, if we want to store 10 numbers, we simply declare an array of size 10.",
      "sub_description": " But what if we don’t know the size while writing the code?",
      "content": [
        {
          "type": "heading",
          "level": "5",
          "text": "For instance:"
        },
        {
          "type": "list",
          "items": [
            "A program where the user decides how many students’ marks to enter.",
            "A program that takes input until the user stops.",
            "A growing list of customer details or names."
          ]
        },
        {
          "type": "paragraph",
          "text": "In such cases, the memory requirement is not fixed, and that’s where dynamic memory allocation comes into play."
        },
        {
          "type": "paragraph",
          "text": "Dynamic memory allocation allows us to request memory at runtime — that is, while the program is running — instead of at compile time."
        },
        {
          "type": "paragraph",
          "text": " It gives us flexibility to create data structures like arrays, linked lists, or matrices whose sizes can grow or shrink as needed."
        },
        {
          "type": "paragraph",
          "text": "To use dynamic memory allocation, C provides four very useful library functions:"
        },
        {
          "type": "list",
          "items": [
            "malloc()",
            "calloc()",
            "realloc()",
            "free()"
          ]
        },
        {
          "type": "paragraph",
          "text": "All these functions are available in the stdlib.h header file."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1. malloc() – Memory Allocation "
        },
        {
          "type": "paragraph",
          "text": "The malloc() function is used to allocate a single block of memory in bytes.It stands for Memory Allocation and gives you a pointer to the beginning of the memory block."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax:"
        },
        {
          "type": "textarea",
          "text": "ptr = (castType*) malloc(size_in_bytes);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Here:"
        },
        {
          "type": "list",
          "items": [
            "ptr → pointer variable that will store the address of the allocated memory.",
            "size_in_bytes → the total amount of memory you need, in bytes."
          ]
        },
        {
          "type": "paragraph",
          "text": "For example, if you want to store 5 integers:"
        },
        {
          "type": "textarea",
          "text": "int *ptr;\nptr = (int*) malloc(5 * sizeof(int));"
        },
        {
          "type": "paragraph",
          "text": "This line requests memory for 5 integers. The sizeof(int) ensures that memory is allocated according to the system’s integer size (usually 4 bytes each)."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Important Notes: "
        },
        {
          "type": "list",
          "items": [
            "The memory allocated using malloc() contains garbage values (random data).",
            "If memory allocation fails, malloc() returns NULL.",
            "Always check if the pointer is NULL before using it."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int *arr;\narr = (int*) malloc(5 * sizeof(int));\nif (arr == NULL) {\n    printf(\"Memory allocation failed!\");\n} else {\n    printf(\"Memory allocated successfully!\");\n}"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. calloc() – Contiguous Allocation "
        },
        {
          "type": "paragraph",
          "text": "The calloc() function is similar to malloc(), but with two differences: "
        },
        {
          "type": "list",
          "items": [
            "It allows you to allocate multiple blocks of memory at once.",
            "It automatically initializes all elements to zero."
          ]
        },
        {
          "type": "paragraph",
          "text": "It stands for Contiguous Allocation because it allocates continuous memory blocks."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax:"
        },
        {
          "type": "textarea",
          "text": "ptr = (castType*) calloc(num_elements, size_in_each_element);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int *arr;\n arr = (int*) calloc(5 , sizeof(int));"
        },
        {
          "type": "paragraph",
          "text": "This allocates space for 5 integers, all initialized to 0."
        },
        {
          "type": "paragraph",
          "text": "So, if you are creating an array or want initialized values, calloc() is a better choice."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. realloc() – Reallocation of Memory "
        },
        {
          "type": "paragraph",
          "text": "Sometimes, you may realize that the allocated memory is not enough or is too much."
        },
        {
          "type": "paragraph",
          "text": "Instead of starting from scratch, C gives us a convenient function — realloc() — to resize the already allocated memory."
        },
        {
          "type": "paragraph",
          "text": "It can increase or decrease the memory size and keep the existing data safe."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax:"
        },
        {
          "type": "textarea",
          "text": "ptr = realloc(ptr, new_size_in_bytes);"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "int *arr;\narr = (int*) malloc(3 * sizeof(int));   // allocate memory for 3 integers\narr = (int*) realloc(arr, 5 * sizeof(int));   // increase memory for 5 integers"
        },
        {
          "type": "paragraph",
          "text": "Here, the array arr now has space for 5 integers instead of 3."
        },
        {
          "type": "paragraph",
          "text": " The old data remains intact, and the new memory is added at the end."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "When to use realloc():"
        },
        {
          "type": "list",
          "items": [
            "When user input increases or decreases dynamically.",
            "When you need flexible data storage (like in user-controlled lists or arrays)."
          ]
        },
        {
          "type": "paragraph",
          "text": " If realloc() fails, it returns NULL — so it’s safer to store the new pointer in a temporary variable first."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4. free() – Freeing Allocated Memory"
        },
        {
          "type": "paragraph",
          "text": "Whenever we use malloc(), calloc(), or realloc(), the allocated memory stays reserved until we explicitly release it."
        },
        {
          "type": "paragraph",
          "text": " If we forget to release it, the system cannot reuse it, leading to a memory leak."
        },
        {
          "type": "paragraph",
          "text": "To prevent this, we use the free() function."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Syntax:"
        },
        {
          "type": "textarea",
          "text": "free(ptr)"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example: "
        },
        {
          "type": "textarea",
          "text": "free(arr)"
        },
        {
          "type": "paragraph",
          "text": "After freeing, the pointer arr should be set to NULL to avoid accidentally accessing freed memory (called a dangling pointer)."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Good practice:"
        },
        {
          "type": "textarea",
          "text": "free(arr) \narr = NULL;"
        },
        {
          "type": "paragraph",
          "text": "This ensures your program doesn't access invalid memory."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "5. Memory Management Best Practices"
        },
        {
          "type": "paragraph",
          "text": "Managing memory correctly is very important in C programming because you have manual control over memory allocation and deallocation."
        },
        {
          "type": "paragraph",
          "text": "Here are some helpful tips: "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Always check for NULL: "
        },
        {
          "type": "paragraph",
          "text": " After using malloc(), calloc(), or realloc(), make sure to check if the returned pointer is NULL. If it is, memory allocation has failed."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Always free memory: "
        },
        {
          "type": "paragraph",
          "text": "When you are done using dynamically allocated memory, call free() to release it."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Avoid dangling pointers: "
        },
        {
          "type": "paragraph",
          "text": "Once you free memory, set the pointer to NULL."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Use sizeof() correctly: "
        },
        {
          "type": "paragraph",
          "text": "Always calculate size using sizeof(type) to ensure portability across systems."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Don’t overwrite pointers before freeing them: "
        },
        {
          "type": "paragraph",
          "text": " If you assign a new memory block to a pointer before freeing the old one, you’ll lose access to the old memory — leading to a memory leak."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "6. Avoiding Memory Leaks"
        },
        {
          "type": "paragraph",
          "text": "A memory leak occurs when a program allocates memory but forgets to release it."
        },
        {
          "type": "paragraph",
          "text": "Over time, the unused memory accumulates, slowing down or crashing the program — especially in long-running applications like servers or background processes."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example of a Memory Leak :"
        },
        {
          "type": "textarea",
          "text": "int *ptr = (int*) malloc(5 * sizeof(int));\n ptr = (int*) malloc(10 * sizeof(int)); // old memory is lost!"
        },
        {
          "type": "paragraph",
          "text": "Here, the original 5-integer block was never freed before assigning a new one. The system now has no way to access that memory again — it’s \"leaked.\""
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Correct Approach : "
        },
        {
          "type": "textarea",
          "text": "int *ptr = (int*) malloc(5 * sizeof(int));\nfree(ptr); // release old memory\nptr = (int*) malloc(10 * sizeof(int));"
        },
        {
          "type": "paragraph",
          "text": "By freeing the old memory first, we ensure there are no leaks."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "7. Why Dynamic Memory Allocation Matters"
        },
        {
          "type": "paragraph",
          "text": "Dynamic memory allocation is used widely in real-world programs:"
        },
        {
          "type": "list",
          "items": [
            "<b> In databases: </b> to store variable-size records.",
            "<b> In games: </b> to handle dynamic objects like players, enemies, or items.",
            "<b> In file processing: </b> to read files of unknown length.",
            "<b> In data structures: </b> such as linked lists, trees, or graphs that grow and shrink at runtime."
          ]
        },
        {
          "type": "paragraph",
          "text": "Without dynamic allocation, we would need to predefine sizes for everything — wasting memory or risking insufficient space."
        }
      ]
    }
  ],
  "Advanced Concpets ": [
    {
      "title": "Introduction",
      "description": "In this module, we explore some of the advanced features of C programming that give developers more control, flexibility, and efficiency in writing programs. ",
      "sub_description": "You will learn how C handles memory addresses and pointer operators, how macros and preprocessor directives simplify code, the different storage classes that define the lifetime and visibility of variables, and how to structure large projects using header files and modular code organization.",
      "additional_info": "These concepts are essential for writing optimized, professional, and maintainable C programs, and they form the foundation for working on real-world projects in C.",
      "content": [
        {
          "type": "heading",
          "level": "3",
          "text": "1. Memory Address and &, * Operators : "
        },
        {
          "type": "paragraph",
          "text": "One of the most powerful aspects of C is direct memory manipulation using pointers. To work effectively with pointers, you need to understand two important operators:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Address-of Operator (&): "
        },
        {
          "type": "paragraph",
          "text": "Used to get the memory address of a variable."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int x = 10;\n printf(\"Address of x: %p\", &x);"
        },
        {
          "type": "paragraph",
          "text": " Here, &x gives the address where the variable x is stored."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Dereference Operator (*): "
        },
        {
          "type": "paragraph",
          "text": "Used to access the values stored at a memory address."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int x = 10;\nint *ptr = &x;\nprintf(\"Value of x using pointer: %d\", *ptr);"
        },
        {
          "type": "paragraph",
          "text": "Here, *ptr retrieves the value of x from its memory address."
        },
        {
          "type": "paragraph",
          "text": "Together, & and * allow programmers to manipulate memory directly, making C both powerful and efficient."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2. Macros and #define : "
        },
        {
          "type": "paragraph",
          "text": "Macros are handled by the preprocessor before the actual compilation begins. They are created using the #define directive. "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Constant Macros : "
        },
        {
          "type": "paragraph",
          "text": "Define symbolic names for values to improve readability."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "#define PI 3.14159\nprintf(\"Area of circle: %f\", PI * r * r);"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Function-like Macros : "
        },
        {
          "type": "paragraph",
          "text": "Create short, reusable code snippets."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "#define SQUARE(x) ((x) * (x))\nprintf(\"Square of 5: %d\", SQUARE(5));"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Advantages of Macros : "
        },
        {
          "type": "list",
          "items": [
            "Code becomes more readable and maintainable.",
            "Speeds up execution(no function call overhead)."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Disadvantages of Macros : "
        },
        {
          "type": "list",
          "items": [
            "No type checking.",
            "Can lead to unexpected errors if not used carefully."
          ]
        },
        {
          "type": "paragraph",
          "text": " Macros are useful, but in modern coding, const, inline, and enum are often safer alternatives."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3. Storage Classes in C : "
        },
        {
          "type": "paragraph",
          "text": "Storage classes define scope (visibility), lifetime (duration), and default value of variables in a program."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(a) auto :"
        },
        {
          "type": "list",
          "items": [
            "Default storage class for local variables.",
            "Exists only inside the function where it is defined."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "void test() {\n    auto int x = 10;  \n    printf(\"%d\", x);\n};"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(b) static  :"
        },
        {
          "type": "list",
          "items": [
            "Retains its value between function calls.",
            "The default value is 0."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "void counter() {\n    static int count = 0;\n    count++;\n    printf(\"%d \", count);\n}"
        },
        {
          "type": "paragraph",
          "text": "Calling counter() multiple times will keep incrementing count rather than resetting it."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(c) extern :"
        },
        {
          "type": "list",
          "items": [
            "Declares a global variable defined in another file or outside the function.",
            "Used to share variables across multiple files."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "// file1.c\nint num = 100;\n// file2.c\nextern int num;\nprintf(\"%d\", num);"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(d) register :"
        },
        {
          "type": "list",
          "items": [
            "Suggests storing the variable in a CPU register for faster access.",
            "Cannot use & on register variables (since they may not have a memory location)."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "register int i;\n for(i = 0; i < 1000; i++) {\n    // Fast access loop\n}"
        },
        {
          "type": "paragraph",
          "text": "Choosing the right storage class helps optimize performance and manage memory efficiently."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4. Organizing Code: Header Files and Modular Code : "
        },
        {
          "type": "paragraph",
          "text": "As projects grow larger, writing everything in a single .c file becomes messy. C provides mechanisms to organize code effectively:"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(a) Header Files (.h) :"
        },
        {
          "type": "list",
          "items": [
            "Contain function declarations, macros, and constants.",
            "Reusable across multiple source files."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "// mathutils.h\nint add(int, int);\n#define PI 3.14\n// main.c\n#include \"mathutils.h\"\nint main() {\n    printf(\"%d\", add(2,3));\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "(b) Modular Code :"
        },
        {
          "type": "paragraph",
          "text": "Splitting a project into multiple files for better readability and maintainability."
        },
        {
          "type": "list",
          "items": [
            "<b> Header File (.h) : </b> Declarations (what functions/variables exist).",
            "<b> Implementation File (.c) : </b> Definitions (actual logic).",
            "<b> Main File (.h) : </b>  Calls functions."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "paragraph",
          "text": "This approach makes debugging easier, allows team collaboration, and promotes code reusability."
        }
      ]
    }
  ],
  "Error Handling and Debugging": [
    {
      "title": "Introduction to  Error Handling and Debugging",
      "description": "It‍‌‍‍‌‍‌‍‍‌ is not the case that programming is all the time about writing code that works perfectly from the first try. Even to be fair, experienced programmers are not immune to errors - and this is perfectly fine! The most important thing is to learn how to locate, comprehend, and rectify those errors.",
      "sub_description": " It is called Error Handling and Debugging, which is the process of recognizing and fixing errors that come to be, and it’s one of the major components of the programmer’s journey.",
      "additional_info": "We will learn in this module the kinds of errors that are typical, the reasons for these occurring, fixing them, the meaning of warnings, the role of debugging, what NULL is, and how to validate user inputs so as not to be able to make the program crash ‍‌‍‍‌‍‌‍‍‌unexpectedly.",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": " 1. Common C Errors"
        },
        {
          "type": "heading",
          "level": "4",
          "text": " What are Errors?"
        },
        {
          "type": "paragraph",
          "text": "Errors are flaws in a program that prohibit it from running or giving the correct output. Such errors may be in the code which is being typed, during compiling, or when the program is executed."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why do we need to handle errors?"
        },
        {
          "type": "paragraph",
          "text": "Improper handling of errors may result in the program going silent, giving wrong outputs or even crashing your system.As a result of recognising and managing errors, we make them safer and more understandable to users."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.1 Syntax Errors"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What is it?"
        },
        {
          "type": "paragraph",
          "text": "A syntax error is a situation where the rules of grammar for C language are violated."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why does it happen?"
        },
        {
          "type": "paragraph",
          "text": "Some of these reasons are missing semicolons, unmatched brackets, misspelled keywords, or incorrect punctuation."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "printf(\"Hello World\"); // Missing semicolon"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "How to fix:"
        },
        {
          "type": "paragraph",
          "text": "It is a good habit to always take into account the messages of the compiler. They inform you about the mistake and the location.\n Check again your punctuation, parentheses, and ​‍​‌‍​‍‌​‍​‌‍​‍‌keywords."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.2 Logical Errors"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What is it?"
        },
        {
          "type": "paragraph",
          "text": "Logical error refers to a situation where the program is executable but it returns the wrong output."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why does it happen?"
        },
        {
          "type": "paragraph",
          "text": "It is a case when the logic or formula in the code is incorrect, while the syntax is correct."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int a = 10, b = 5;\nprintf(\"%d\", a - b);  // You intended to add but used subtraction"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "How to fix:"
        },
        {
          "type": "paragraph",
          "text": " Firstly, check your formulas and secondly, test your code with different inputs.\n Additionally, use printing commands to check whether the variables carry the correct values at a certain point of the ​‍​‌‍​‍‌​‍​‌‍​‍‌program."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "1.3 Runtime Errors"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What is it?"
        },
        {
          "type": "paragraph",
          "text": " Runtime errors are those which happen during the execution of a program."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why does it happen?"
        },
        {
          "type": "paragraph",
          "text": "Most of the time, this happens because your code is doing something that is not allowed—for example, dividing by zero or accessing memory in an invalid manner."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int a = 5, b = 0;\nprintf(\"%d\", a / b);  // Division by zero – causes runtime error"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "How to fix:"
        },
        {
          "type": "paragraph",
          "text": "Validate inputs before using them.\n Always check conditions (like if (b != 0)) before performing operations."
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 2. Understanding Warnings and Debugging Techniques"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2.1 What are Compiler Warnings?"
        },
        {
          "type": "paragraph",
          "text": "A warning is a message from the compiler telling you that something in your code might cause a problem later — but it doesn’t stop the program from compiling."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why do we use warnings?"
        },
        {
          "type": "paragraph",
          "text": "Warnings are one of the means that prevent bugs and help the quality of the code to be kept at a high level.\n Not paying attention to them may not bring troubles right away but in general, it can end up with errors later on."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example Warning : "
        },
        {
          "type": "textarea",
          "text": "warning : variable 'x' set but not used"
        },
        {
          "type": "paragraph",
          "text": "Simply, it says that you have made a variable but have never utilized it."
        },
        {
          "type": "paragraph",
          "text": "<b> Fix : Review and clean up unused variables or unnecessary code.</b>"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2.2 What is Debugging?"
        },
        {
          "type": "paragraph",
          "text": "Debugging is the process of identifying errors in your code and then fixing them. It’s basically essential programming because it leads to the understanding of the program’s behavior step by step."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why do we debug programs?"
        },
        {
          "type": "list",
          "items": [
            "To find errors and to help error causes.",
            "To help the program run efficiently and correctly.",
            "To learn/gain knowledge of which logical path will be taken during execution."
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Debugging Techniques"
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Using Print Statements : "
        },
        {
          "type": "paragraph",
          "text": "Insert printf() calls to output variable values and program flow."
        },
        {
          "type": "textarea",
          "text": " printf(\"Value of x = %d\\n\", x);"
        },
        {
          "type": "list",
          "items": [
            "That helps you locate the point of the program where the error occurs.",
            "<b>Testing Small Parts:</b> Instead of writing the whole program at once, test small parts of your code.\n Debugging small parts of the code is far simpler.",
            "<b>Using Debugger Tools:</b> IDEs like Code::Blocks or Dev C++ have built-in debuggers.You are able to execute your code step by step, define breakpoints, and see variable values.",
            "<b> Peer Review:</b>In some cases, another person can figure out your mistake more quickly than you.If you are totally stuck, get a friend or teacher to check your code."
          ]
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 3. NULL in C Programming"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What is Null?"
        },
        {
          "type": "paragraph",
          "text": "In C, NULL is a special constant that represents an empty or invalid pointer. It means that the pointer is not pointing to any valid memory location yet."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why do we use Null?"
        },
        {
          "type": "paragraph",
          "text": "Using NULL helps prevent the program from accessing garbage memory values or random memory addresses. \n It ensures the pointer is safely initialized before being used."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int *ptr = NULL;\nif (ptr == NULL)\n    printf(\"Pointer is empty.\\n\");\nelse\n    printf(\"Pointer points to a valid memory location.\\n\");"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Remember : "
        },
        {
          "type": "paragraph",
          "text": " Always initialize your pointers as NULL until they are assigned a valid memory address.\n This helps prevent crashes and makes debugging easier."
        },
        {
          "type": "heading",
          "level": "2",
          "text": "4. Input Validation Methods"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "What is Input Validation? "
        },
        {
          "type": "paragraph",
          "text": "Input validation is basically your program checking what the user has entered before it goes on with handling those inputs. Input Validation is a way to confirm that the data entered is proper and that won’t produce errors or crashes. "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Why is Input Validation important? "
        },
        {
          "type": "list",
          "items": [
            "Input validation is a guard against valid or unexpected inputs.",
            "Calculations are kept safe through it (for example, it avoids division by zero).",
            "Also, it makes the program more user-friendly and reliable."
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\nint main() {\n    int a, b;\n    printf(\"Enter two numbers: \");\n    scanf(\"%d %d\", &a, &b);\n    if (b == 0) {\n        printf(\"Error! Division by zero is not allowed.\\n\");\n    } else {\n        printf(\"Result: %d\\n\", a / b);\n    }\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "Tips for Good Input Validation: "
        },
        {
          "type": "list",
          "items": [
            "Always check if the input value is within the expected range.",
            "Verify the data type (number, character, etc.).",
            "Use loops to re-ask for input until the user provides valid data."
          ]
        }
      ]
    }
  ],
  "C Standard Library and Math Functions": [
    {
      "title": "Introduction to C Standard Library and Math Functions",
      "description": "Programming‍‌‍‍‌‍‌‍‍‌ in C can be a lot more effective and cleaner if you use the C Standard Library. Rather than coding all the logic on your own, you can just include the files of a library that already has functions for math, input/output, string manipulation, memory management, and many other things.",
      "sub_description": "We will find out what the C Standard Library is, how to use math functions (math.h), and get to know the most essential utility libraries like stdlib.h and string.h in this module.",
      "additional_info": "Besides that, you will be able to create your own utility functions as if they were the built-in ‍‌‍‍‌‍‌‍‍‌ones.",
      "content": [
        {
          "type": "heading",
          "level": "2",
          "text": "1. Understanding the C Standard Library"
        },
        {
          "type": "heading",
          "level": "3",
          "text": "What is the C Standard Library?"
        },
        {
          "type": "paragraph",
          "text": "The C Standard Library is a group of header files which include functions and macros that are frequently used. These functions enable programmers to perform the following tasks:"
        },
        {
          "type": "list",
          "items": [
            "Mathematical operations",
            "Handling strings",
            "Allocating memory",
            "Generating random numbers",
            "Working with input/output",
            "Managing program execution"
          ]
        },
        {
          "type": "paragraph",
          "text": "Instead of making everything new, the Standard Library still takes less time and fewer errors are committed. The library provides already tested and optimized predefined functions."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Why do we use the Standard Library?"
        },
        {
          "type": "paragraph",
          "text": "Using the C Standard Library:"
        },
        {
          "type": "list",
          "items": [
            "Programs become shorter and easier to write",
            "Helps avoid copying logic repeatedly",
            "Ensures that the code you write is reliable and efficient",
            "Provides solutions for common tasks that are generally used in C programs"
          ]
        },
        {
          "type": "heading",
          "level": "4",
          "text": "How to include a library?"
        },
        {
          "type": "textarea",
          "text": "#include <stdio.h>\n#include <math.h>\n#include <stdlib.h>\n#include <string.h>"
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 2. math.h Library Functions"
        },
        {
          "type": "paragraph",
          "text": "The​‍​‌‍​‍‌​‍​‌‍​‍‌ math.h library is the collection of functions performing various mathematical operations which can be complex, but by using those functions you don’t have to write the formula manually."
        },
        {
          "type": "paragraph",
          "text": "All those functions return double values, and if you want to use them, you have to include math.h first."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2.1 What is math.h?"
        },
        {
          "type": "paragraph",
          "text": "math.h is  C header file that come with necessary functions to do math calculations like : "
        },
        {
          "type": "list",
          "items": [
            "Square root",
            "Power",
            "Absolute Value",
            "Trigonometric functions",
            "Logarithmic functions",
            "Rounding"
          ]
        },
        {
          "type": "paragraph",
          "text": "Without this library, performing advanced calculations would require writing complex formulas manually."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "2.2 Common math.h Functions "
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. sqrt(x) - Square Root"
        },
        {
          "type": "paragraph",
          "text": "<b> Definition :</b> sqrt() is a function that returns the square root of a number. Also only positive numbers can be used with this function, because a negative number does not have a real square ​‍​‌‍​‍‌​‍​‌‍​‍‌root."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "double r = sqrt(49);  \t\t // r = 7"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. pow(base, exponent) – Power Function"
        },
        {
          "type": "paragraph",
          "text": "<b> Definition :</b> pow() raises a number to a given power. It is extremely useful for calculations involving exponents."
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "double r = pow(2,4);  \t\t // r = 16 (2 ^ 4)"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3. abs() and fabs() – Absolute Value"
        },
        {
          "type": "paragraph",
          "text": "<b> Definition :</b> Absolute value means the positive version of a number."
        },
        {
          "type": "list",
          "items": [
            "abs() → for integers",
            "fabs() → for floating-point numbers"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int a = abs(-12);      // 12\ndouble b = fabs(-3.7); // 3.7"
        },
        {
          "type": "heading",
          "level": "4",
          "text": " 4. Trigonometric Functions "
        },
        {
          "type": "paragraph",
          "text": "Used for mathematical and engineering programs."
        },
        {
          "type": "list",
          "items": [
            "sin(x) → Sine",
            "cos(x) → Cosine",
            "tan(x) → Tangent"
          ]
        },
        {
          "type": "paragraph",
          "text": "These functions expect angles in radians, not degrees."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "5. Rounding Functions"
        },
        {
          "type": "list",
          "items": [
            "ceil(x) → rounds up",
            "floor(x) → rounds down",
            "round(x) → rounds to nearest whole number"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "double x = ceil(4.2);  \t\t // 5\ndouble y = floor(4.8); \t\t// 4"
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 3. Overview of stdlib.h"
        },
        {
          "type": "paragraph",
          "text": "The stdlib.h library contains general-purpose functions used in almost every C program. \n It provides tools for : "
        },
        {
          "type": "list",
          "items": [
            "Memory allocation",
            "Type Conversions",
            "random number generation",
            "Program control (exit, abort)",
            "sorting and searching"
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3.1 What is stdlib.h?"
        },
        {
          "type": "paragraph",
          "text": "stdlib.h is a header file that includes functions performing tasks that don’t belong to a specific category but are essential for building reliable programs. This library is especially  important in medium-to-large size programs."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "3.2 Important stdlib.h Functions"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3.2.1 Type Conversion Functions"
        },
        {
          "type": "paragraph",
          "text": "Convert strings into numbers:"
        },
        {
          "type": "list",
          "items": [
            "atoi() → converts a string to int",
            "atof() → converts a string to float",
            "atol() → converts a string to long"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int num = atoi(\"1234\");  \t\t // num = 1234"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3.2.2. Random Number Generation"
        },
        {
          "type": "list",
          "items": [
            "rand() → generates a random number",
            "srand() → sets a new seed for randomness"
          ]
        },
        {
          "type": "heading",
          "level": "5",
          "text": "Example : "
        },
        {
          "type": "textarea",
          "text": "int r= rand() % 10;  \t\t // random number between 0-9"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3.2.3. Memory Management Functions"
        },
        {
          "type": "paragraph",
          "text": "stdlib.h contains functions that allow your program to allocate and free memory during runtime."
        },
        {
          "type": "list",
          "items": [
            "malloc() → allocates memory",
            "calloc() → allocates memory & initializes with zero",
            "realloc() → resizes previously allocated memory",
            "free() – releases memory"
          ]
        },
        {
          "type": "paragraph",
          "text": "These functions are critical for working with dynamic arrays and data structures."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "3.2.4. Program Termination"
        },
        {
          "type": "paragraph",
          "text": "exit() ends the program immediately, which is useful for error handling."
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 4. Overview of string.h "
        },
        {
          "type": "paragraph",
          "text": "Working with strings in C is not as simple as in other languages. \n The string.h library makes string handling easier and safer by providing predefined functions."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4.1 What is string.h? "
        },
        {
          "type": "paragraph",
          "text": "string.h handles operations related to strings, such as:"
        },
        {
          "type": "list",
          "items": [
            "finding length",
            "copying strings",
            "comparing strings",
            "concatenating",
            "searching for substrings"
          ]
        },
        {
          "type": "paragraph",
          "text": "Instead of manually looping through characters, string.h gives ready-made tools to work efficiently."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "4.2 Common string.h functions"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4.2.1 strlen(str) – String Length "
        },
        {
          "type": "paragraph",
          "text": "Returns the number of characters in a string."
        },
        {
          "type": "textarea",
          "text": "int len = strlen(\"Hello\"); \t\t // len = 5"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4.2.2. strcpy(dest, src) – Copy Strings "
        },
        {
          "type": "paragraph",
          "text": "Copies contents of one string to another."
        },
        {
          "type": "textarea",
          "text": "strcpy(name, \"WebCooks\"); \t\t // name now contains \"WebCooks\""
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4.2.3. strcat(str1, str2) – Concatenate "
        },
        {
          "type": "paragraph",
          "text": "Merges two strings by appending str2 to str1."
        },
        {
          "type": "textarea",
          "text": "strcat(first, last); \t\t // first now contains \"JohnDoe\""
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4.2.4. strcmp(s1, s2) – Compare Strings"
        },
        {
          "type": "paragraph",
          "text": "Returns : "
        },
        {
          "type": "textarea",
          "text": "strcat(first, last); \t\t // first now contains \"JohnDoe\""
        },
        {
          "type": "list",
          "items": [
            "0 → Both strings are equal",
            ">0 → str1 is greater",
            "<0 → str1 is smaller"
          ]
        },
        {
          "type": "paragraph",
          "text": "Used in sorting, searching, and condition checks."
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4.2.5. strstr(str, sub) – Find Substring"
        },
        {
          "type": "paragraph",
          "text": "Searches if a smaller string exists inside another string.If found, it returns the position where the substring starts; otherwise, it returns NULL."
        },
        {
          "type": "textarea",
          "text": "strstr(sentence, word); \t\t // returns pointer to 'word' in 'sentence' if found"
        },
        {
          "type": "heading",
          "level": "2",
          "text": " 5. Custom Utility Functions "
        },
        {
          "type": "paragraph",
          "text": "Built-in functions are powerful, but you can also create your own utility functions to simplify repeated logic."
        },
        {
          "type": "heading",
          "level": "3",
          "text": "What are Custom Utility Functions? "
        },
        {
          "type": "paragraph",
          "text": "Custom utility functions are user-defined functions created to perform specific tasks repeatedly throughout a program.They help make code:"
        },
        {
          "type": "list",
          "items": [
            "cleaner",
            "more organized",
            "easy to read",
            "reusable"
          ]
        },
        {
          "type": "heading",
          "level": "3",
          "text": "Examples of Useful Custom Functions"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "1. Function to find maximum of two numbers"
        },
        {
          "type": "textarea",
          "text": "int max(int a, int b) {\n    return (a > b) ? a : b;\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "2. Function to check if a number is prime"
        },
        {
          "type": "textarea",
          "text": "int isPrime(int n) {\n    if (n <= 1) return 0;\n    for (int i = 2; i <= sqrt(n); i++) {\n        if (n % i == 0)\n            return 0;\n    }\n    return 1;\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": " 3. Swap two numbers"
        },
        {
          "type": "textarea",
          "text": "void swap(int *x, int *y) {\n    int temp = *x;\n    *x = *y;\n    *y = temp;\n}"
        },
        {
          "type": "heading",
          "level": "4",
          "text": "4. Custom power function (if you don’t want to use pow)"
        },
        {
          "type": "textarea",
          "text": "int power(int base, int exp) {\n    int result = 1;\n    for (int i = 0; i < exp; i++) {\n        result *= base;\n    }\n    return result;\n}"
        }
      ]
    }
  ]
}