Untitled

 avatar
unknown
plain_text
2 years ago
6.1 kB
4
Indexable
{
  "topics": [
    {
      "name": "Data Types",
      "examples": [
        {
          "pro1": "int num = 10;"
        },
        {
          "pro2": "float average = 3.14;"
        },
        {
          "pro3": "char letter = 'A';"
        },
        {
          "pro4": "double pi = 3.14159265359;"
        },
        {
          "pro5": "bool flag = true;"
        }
      ]
    },
    {
      "name": "Variables",
      "examples": [
        {
          "pro1": "int age;"
        },
        {
          "pro2": "float salary = 1000.50;"
        },
        {
          "pro3": "char initial = 'J';"
        },
        {
          "pro4": "double pi = 3.14159;"
        },
        {
          "pro5": "bool flag = false;"
        }
      ]
    },
    {
      "name": "Constants",
      "examples": [
        {
          "pro1": "const int MAX_VALUE = 100;"
        },
        {
          "pro2": "const float PI = 3.14;"
        },
        {
          "pro3": "const char NEW_LINE = '\\n';"
        },
        {
          "pro4": "const double EULER_NUMBER = 2.71828;"
        },
        {
          "pro5": "const bool DEBUG_MODE = true;"
        }
      ]
    },
    {
      "name": "Operators",
      "examples": [
        {
          "pro1": "int sum = a + b;"
        },
        {
          "pro2": "float result = x / y;"
        },
        {
          "pro3": "int remainder = x % y;"
        },
        {
          "pro4": "int product = a * b;"
        },
        {
          "pro5": "bool isEqual = a == b;"
        }
      ]
    },
    {
      "name": "Control Flow Statements",
      "examples": [
        {
          "pro1": "if (x > y) {\n    printf(\"x is greater than y\");\n}"
        },
        {
          "pro2": "if (age >= 18) {\n    printf(\"You are an adult\");\n} else {\n    printf(\"You are a minor\");\n}"
        },
        {
          "pro3": "for (int i = 0; i < 10; i++) {\n    printf(\"%d\\n\", i);\n}"
        },
        {
          "pro4": "while (x < 100) {\n    x += 10;\n}"
        },
        {
          "pro5": "switch (day) {\n    case 1:\n        printf(\"Sunday\");\n        break;\n    case 2:\n        printf(\"Monday\");\n        break;\n    default:\n        printf(\"Invalid day\");\n        break;\n}"
        }
      ]
    },
    {
      "name": "Functions",
      "examples": [
        {
          "pro1": "int add(int a, int b) {\n    return a + b;\n}"
        },
        {
          "pro2": "float calculateAverage(float[] numbers, int size) {\n    float sum = 0;\n    for (int i = 0; i < size; i++) {\n        sum += numbers[i];\n    }\n    return sum / size;\n}"
        },
        {
          "pro3": "void greet() {\n    printf(\"Hello, World!\");\n}"
        },
        {
          "pro4": "int factorial(int n) {\n    if (n <= 1) {\n        return 1;\n    }\n    return n * factorial(n - 1);\n}"
        },
        {
          "pro5": "bool isPrime(int num) {\n    if (num < 2) {\n        return false;\n    }\n    for (int i = 2; i <= num / 2; i++) {\n        if (num % i == 0) {\n            return false;\n        }\n    }\n    return true;\n}"
        }
      ]
    },
    {
      "name": "Arrays",
      "examples": [
        {
          "pro1": "int numbers[5] = {1, 2, 3, 4, 5};"
        },
        {
          "pro2": "float grades[] = {85.5, 90.0, 77.5, 92.5};"
        },
        {
          "pro3": "char name[10] = \"John\";"
        },
        {
          "pro4": "int matrix[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};"
        },
        {
          "pro5": "bool flags[8] = {true, false, false, true, true, false, true, false};"
        }
      ]
    },
    {
      "name": "Pointers",
      "examples": [
        {
          "pro1": "int *ptr;"
        },
        {
          "pro2": "float *pi = &value;"
        },
        {
          "pro3": "char *str = \"Hello\";"
        },
        {
          "pro4": "int num = 10;\nint *p = &num;\nprintf(\"%d\", *p);"
        },
        {
          "pro5": "int arr[] = {1, 2, 3};\nint *ptr = arr;\nprintf(\"%d\", *ptr);"
        }
      ]
    },
    {
      "name": "Structures",
      "examples": [
        {
          "pro1": "struct Point {\n    int x;\n    int y;\n};\n\nstruct Point p1;\np1.x = 10;\np1.y = 20;"
        },
        {
          "pro2": "typedef struct {\n    float radius;\n    float center_x;\n    float center_y;\n} Circle;\n\nCircle c1;\nc1.radius = 5.0;\nc1.center_x = 0.0;\nc1.center_y = 0.0;"
        },
        {
          "pro3": "struct Person {\n    char name[50];\n    int age;\n};\n\nstruct Person p;\nstrcpy(p.name, \"John\");\np.age = 25;"
        },
        {
          "pro4": "struct Book {\n    char title[100];\n    char author[100];\n    float price;\n};\n\nstruct Book b;\nstrcpy(b.title, \"The Great Gatsby\");\nstrcpy(b.author, \"F. Scott Fitzgerald\");\nb.price = 10.99;"
        },
        {
          "pro5": "struct Rectangle {\n    int width;\n    int height;\n};\n\nstruct Rectangle r = {5, 10};\nint area = r.width * r.height;"
        }
      ]
    },
    {
      "name": "File Handling",
      "examples": [
        {
          "pro1": "FILE *file = fopen(\"file.txt\", \"r\");\nif (file == NULL) {\n    printf(\"Failed to open file\");\n} else {\n    // File operations\n    fclose(file);\n}"
        },
        {
          "pro2": "FILE *file = fopen(\"data.txt\", \"w\");\nif (file == NULL) {\n    printf(\"Failed to create file\");\n} else {\n    // File operations\n    fclose(file);\n}"
        },
        {
          "pro3": "FILE *file = fopen(\"file.txt\", \"a\");\nif (file == NULL) {\n    printf(\"Failed to open file\");\n} else {\n    // File operations\n    fclose(file);\n}"
        },
        {
          "pro4": "FILE *file = fopen(\"file.txt\", \"r\");\nif (file != NULL) {\n    // File operations\n    fclose(file);\n}"
        },
        {
          "pro5": "FILE *file = fopen(\"data.bin\", \"wb\");\nif (file == NULL) {\n    printf(\"Failed to create binary file\");\n} else {\n    // File operations\n    fclose(file);\n}"
        }
      ]
    }
  ]
}
Editor is loading...