{
  "C++ Introduction": [
    {
      "title": "Introduction to C++",
      "description": "C++ is a general-purpose programming language with a bias toward systems programming that is a better C. It supports data abstraction, object oriented programming, and generic programming.",
      "sub_description": "It was originally designed and implemented by Bjarne Stroustrup in Bell Telephone Laboratories Computer Science Research Center in Murray Hill, New Jersey in 1979.",
      "additional_info": "The most significant development in C++ after its initial decade of growth was the STL — the standard library's facilities for containers and algorithms. Alex Stepanov is the inventor of the STL and a pioneer of generic programming.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "The Basics"
        },
        {
          "type": "paragraph",
          "text": "To get a computer to do something, you have to tell it exactly — what to do. Such a description of \"what to do\" is called a program, and programming is the activity of writing and testing such programs."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "First Program"
        },
        {
          "type": "textarea",
          "text": "//This program outputs the message \"Hello World!\" to the monitor.\n#include <iostream>\nusing namespace std;\nint main() {\n    cout<<\"Hello World!\";\n    return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "It prints the characters Hello World! followed by a newline. In C++, string literals are delimited by double quotes (\"). The \\n is a \"special character\" indicating a newline."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Why Learn C++?"
        },
        {
          "type": "list",
          "items": [
            "<b>Systems Programming:</b> - C++ gives you fine-grained control over system resources and memory, making it ideal for operating systems, game engines, and embedded systems.",
            "<b>Object-Oriented:</b> - C++ supports classes and objects, enabling modular and reusable code design.",
            "<b>High Performance:</b> - C++ compiles directly to machine code, making it one of the fastest programming languages available.",
            "<b>STL Power:</b> - The Standard Template Library (STL) provides ready-to-use data structures and algorithms.",
            "<b>Industry Standard:</b> - C++ is widely used in finance, gaming, browsers, and embedded software worldwide."
          ]
        }
      ]
    },
    {
      "title": "Comments in C++",
      "description": "Comments are written to describe what the program is intended to do and in general to provide information useful for humans that cannot be directly expressed in code.",
      "sub_description": "Comments are ignored by the compiler and are only meant for humans 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 provide information useful for humans that cannot be directly expressed in code.",
            "To temporarily disable (debug) parts of the code.",
            "To leave notes or reminders for future updates."
          ]
        },
        {
          "type": "heading",
          "level": 3,
          "text": "Single-Line Comment"
        },
        {
          "type": "paragraph",
          "text": "The first line of the program is a typical comment; it simply tells the human reader what the program is supposed to do."
        },
        {
          "type": "textarea",
          "text": "//This program outputs the message \"Hello World!\" to the monitor."
        },
        {
          "type": "heading",
          "level": 3,
          "text": "Multi-Line Comment"
        },
        {
          "type": "textarea",
          "text": "/* This is a multi-line comment.\n   It can span multiple lines.\n   Useful for detailed explanations. */"
        }
      ]
    },
    {
      "title": "Input and Output in C++",
      "description": "Real programs tend to produce results based on some input we give them, rather than just doing the same thing each time we execute them.",
      "sub_description": "To read something, we need somewhere to read into; that is, we need somewhere in the computer's memory to place what we read. It is called a variable.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Standard Output with cout"
        },
        {
          "type": "paragraph",
          "text": "We use the standard output stream, cout, and its output operator << to print values to the screen."
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Standard Input with cin"
        },
        {
          "type": "paragraph",
          "text": "The cin object is used to read input from the user at runtime using the >> operator."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example: Reading User Input"
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n    int age;\n    cout<<\"Enter age: \";\n    cin>>age;\n    cout<<\"Age is \"<<age;\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "The #include<iostream> Directive"
        },
        {
          "type": "paragraph",
          "text": "It instructs the computer to make available (\"to include\") facilities from a file called iostream, which provides cout and cin."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "using namespace std;"
        },
        {
          "type": "paragraph",
          "text": "The statement using namespace std; in C++ imports the entire standard library (std) namespace into the current scope, allowing you to use common elements like cout, cin, and string without typing the std:: prefix."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "The main() Function"
        },
        {
          "type": "paragraph",
          "text": "How does a computer know where to start executing a program? It looks for a function called main and starts executing the instructions it finds there. Every C++ program must have a function called main to tell it where to start executing."
        }
      ]
    }
  ],
  "Basic Syntax, Variables & Data Types": [
    {
      "title": "Variables in C++",
      "description": "The places in which we store data are called objects. To access an object we need a name. A named object is called a variable and has a specific type (such as int or string).",
      "sub_description": "Variables allow C++ programs to store and manipulate data during execution. Every variable must be declared with a type before it can be used.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Declaring and Initializing Variables"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Declaration Statement"
        },
        {
          "type": "textarea",
          "text": "int x, y, z; //declare three integer type variables."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Initialization Statement"
        },
        {
          "type": "textarea",
          "text": "x = 10;  //initialize value of x with 10\ny = 20;  //initialize value of y with 20"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Expression Statement"
        },
        {
          "type": "textarea",
          "text": "z = x + y; //computation"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Constant Expressions"
        },
        {
          "type": "paragraph",
          "text": "Programs typically use a lot of constants. For example, a geometry program might use pi and an inch-to-centimeter conversion program will use a conversion factor such as 2.54. You cannot give a new value after it has been initialized."
        },
        {
          "type": "textarea",
          "text": "const double pi = 3.14159;\npi = 7;  // error: assignment to const"
        }
      ]
    },
    {
      "title": "Keywords and Identifiers in C++",
      "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 are reserved words with predefined meanings. Identifiers are user-defined names for variables, functions, classes, and other program elements.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "1. What are Identifiers?"
        },
        {
          "type": "paragraph",
          "text": "An identifier is a unique, user-defined name assigned to program elements such as variables, functions, classes, structures, arrays, or objects to distinguish them during execution."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Important Rules for Identifiers"
        },
        {
          "type": "list",
          "items": [
            "Only letters (A-Z, a-z), digits (0-9), and underscores (_) are allowed.",
            "Must start with a letter or an underscore. It cannot begin with a digit.",
            "Reserved keywords (such as int, while, return, class) cannot be used.",
            "Lowercase and uppercase letters are distinct — total and Total are separate identifiers."
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "2. What are Keywords?"
        },
        {
          "type": "paragraph",
          "text": "Keywords are predefined, reserved words that carry a unique meaning for the compiler. We cannot use a keyword as an identifier."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Common C++ Keywords"
        },
        {
          "type": "list",
          "items": [
            "int, float, return, class, public, private",
            "if, else, while, for, break, continue",
            "void, this, new, delete, try, catch, throw, const",
            "etc..."
          ]
        }
      ]
    },
    {
      "title": "Data Types in C++",
      "description": "C++ offers the programmer a rich assortment of built-in as well as user defined data types.",
      "sub_description": "Several of the basic types can be modified using one or more of these type modifiers: signed, unsigned, short, long.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Built-in Data Types"
        },
        {
          "type": "list",
          "items": [
            "<b>char</b> — stores a single character (1 byte)",
            "<b>int</b> — stores whole numbers (typically 4 bytes)",
            "<b>short int</b> — shorter integer type (typically 2 bytes)",
            "<b>long int</b> — larger integer type (typically 8 bytes)",
            "<b>float</b> — stores decimal numbers (single precision, 4 bytes)",
            "<b>double</b> — stores decimal numbers (double precision, 8 bytes)"
          ]
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Checking Data Type Sizes with sizeof()"
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n  cout << \"Size of char : \" << sizeof(char) << endl;\n  cout << \"Size of int : \" << sizeof(int) << endl;\n  cout << \"Size of short int : \" << sizeof(short int) << endl;\n  cout << \"Size of long int : \" << sizeof(long int) << endl;\n  cout << \"Size of float : \" << sizeof(float) << endl;\n  cout << \"Size of double : \" << sizeof(double) << endl;\n  return 0;\n}"
        },
        {
          "type": "paragraph",
          "text": "This example uses endl, which inserts a new-line character after every line and the << operator is being used to pass multiple values out to the screen. We are also using sizeof() function to get size of various data types."
        }
      ]
    }
  ],
  "Operators and Expressions in C++": [
    {
      "title": "Operators and Expressions in C++",
      "description": "Operators are used to perform operations on variables and values. C++ divides operators into several groups for different purposes.",
      "sub_description": "Understanding operators is essential to writing expressions, making calculations, comparing values, and controlling program logic.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "Types of Operators in C++"
        },
        {
          "type": "list",
          "items": [
            "Arithmetic operators",
            "Assignment operators",
            "Comparison operators",
            "Logical operators",
            "Bitwise operators"
          ]
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Arithmetic Operators"
        },
        {
          "type": "paragraph",
          "text": "Arithmetic operators are used to perform common mathematical operations."
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n  int x = 10;\n  int y = 3;\n\n  cout << (x + y) << \"\\n\";  // 13\n  cout << (x - y) << \"\\n\";  // 7\n  cout << (x * y) << \"\\n\";  // 30\n  cout << (x / y) << \"\\n\";  // 3 (integer division)\n  cout << (x % y) << \"\\n\";  // 1\n\n  int z = 5;\n  ++z;\n  cout << z << \"\\n\";  // 6\n  --z;\n  cout << z << \"\\n\";  // 5\n  return 0;\n}"
        },
        {
          "type": "heading",
          "level": 2,
          "text": "Increment and Decrement Operators"
        },
        {
          "type": "paragraph",
          "text": "The increment operator ++ adds 1 to its operand, and the decrement operator -- subtracts 1 from its operand."
        },
        {
          "type": "list",
          "items": [
            "x = x+1; is the same as x++;",
            "x = x-1; is the same as x--;"
          ]
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Pre-Increment vs Post-Increment"
        },
        {
          "type": "paragraph",
          "text": "The increment operator can be classified into two types:"
        },
        {
          "type": "list",
          "items": [
            "<b>Pre-Increment Operator (++x)</b> — increments the value before it is used in an expression.",
            "<b>Post-Increment Operator (x++)</b> — uses the current value in the expression, then increments."
          ]
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n    int a = 10, b = 10;\n    cout<<\"Before: a = \"<<a<<\" b = \"<<b<<endl;\n    cout<<\"++a = \"<<++a<<endl;   // Pre-increment\n    cout<<\"b++ = \"<<b++<<endl;   // Post-increment\n    cout<<\"After: a = \"<<a<<\" b = \"<<b;\n    return 0;\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Pre-Decrement vs Post-Decrement"
        },
        {
          "type": "paragraph",
          "text": "The decrement operator can be classified into two types:"
        },
        {
          "type": "list",
          "items": [
            "<b>Pre-decrement Operator (--x)</b> — decrements the value before it is used in an expression.",
            "<b>Post-decrement Operator (x--)</b> — uses the current value in the expression, then decrements."
          ]
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n    int a = 10, b = 10;\n    cout<<\"Before: a = \"<<a<<\" b = \"<<b<<endl;\n    cout<<\"--a = \"<<--a<<endl;   // Pre-decrement\n    cout<<\"b-- = \"<<b--<<endl;   // Post-decrement\n    cout<<\"After: a = \"<<a<<\" b = \"<<b;\n    return 0;\n}"
        }
      ]
    }
  ],
  "Control Flow in C++": [
    {
      "title": "Loops in C++",
      "description": "Loops cause a section of your program to be repeated a certain number of times. The repetition continues while a condition is true. When the condition becomes false, the loop ends.",
      "sub_description": "There are three kinds of loops in C++: the for loop, the while loop, and the do loop.",
      "content": [
        {
          "type": "heading",
          "level": 2,
          "text": "The for Loop"
        },
        {
          "type": "paragraph",
          "text": "The for loop is the easiest C++ loop to understand. All its loop-control elements are gathered in one place."
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Syntax"
        },
        {
          "type": "textarea",
          "text": "for(initialization; condition; increment/decrement) {\n   //statement\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 1: Print 1 2 3 4 5"
        },
        {
          "type": "textarea",
          "text": "for(i = 1; i <= 5; i++) {\n   cout << i << \" \";\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 2: Print Even Numbers — 2 4 6 8 10"
        },
        {
          "type": "textarea",
          "text": "for(int i = 2; i <= 10; i = i + 2) {\n    cout << i << \" \";\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 3: Print in Reverse — 5 4 3 2 1"
        },
        {
          "type": "textarea",
          "text": "for(int i = 5; i >= 1; i--) {\n    cout << i << \" \";\n}"
        },
        {
          "type": "heading",
          "level": 4,
          "text": "Example 4: Print Multiplication Table of 2"
        },
        {
          "type": "paragraph",
          "text": "Desired output: 2 x 1 = 2, 2 x 2 = 4, 2 x 3 = 6 ..."
        },
        {
          "type": "textarea",
          "text": "#include <iostream>\nusing namespace std;\nint main() {\n    int a = 2, c = 0;\n    for(int i = 1; i <= 10; i++) {\n        c = a * i;\n        cout << a << \" x \" << i << \" = \" << c << endl;\n    }\n    return 0;\n}"
        }
      ]
    }
  ]
}
