Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
12 kB
3
Indexable
Never
{
  "topics": [
    {
      "name": "Data Types",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    printf(\"%d\\n\", num);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    float num = 3.14;\n    printf(\"%f\\n\", num);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    char letter = 'A';\n    printf(\"%c\\n\", letter);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    double num = 2.71828;\n    printf(\"%lf\\n\", num);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    unsigned int num = 100;\n    printf(\"%u\\n\", num);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Variables",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int age = 25;\n    printf(\"Age: %d\\n\", age);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    float salary = 5000.50;\n    printf(\"Salary: %f\\n\", salary);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    char grade = 'A';\n    printf(\"Grade: %c\\n\", grade);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    double pi = 3.14159;\n    printf(\"Pi: %lf\\n\", pi);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    unsigned int quantity = 100;\n    printf(\"Quantity: %u\\n\", quantity);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Constants",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\n#define PI 3.14159\n\nint main() {\n    printf(\"Pi: %f\\n\", PI);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\n#define MAX_VALUE 100\n\nint main() {\n    printf(\"Max Value: %d\\n\", MAX_VALUE);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\n#define GREETING \"Hello, World!\"\n\nint main() {\n    printf(\"%s\\n\", GREETING);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nconst double PI = 3.14159;\n\nint main() {\n    printf(\"Pi: %lf\\n\", PI);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nconst int MAX_VALUE = 100;\n\nint main() {\n    printf(\"Max Value: %d\\n\", MAX_VALUE);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Operators",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int a = 5;\n    int b = 2;\n    int sum = a + b;\n    printf(\"Sum: %d\\n\", sum);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    int a = 5;\n    int b = 2;\n    int product = a * b;\n    printf(\"Product: %d\\n\", product);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    int a = 5;\n    int b = 2;\n    int division = a / b;\n    printf(\"Division: %d\\n\", division);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    int a = 5;\n    int b = 2;\n    int remainder = a % b;\n    printf(\"Remainder: %d\\n\", remainder);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    int a = 5;\n    int b = 2;\n    int difference = a - b;\n    printf(\"Difference: %d\\n\", difference);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Control Flow Statements",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    if (num > 0) {\n        printf(\"Positive number\\n\");\n    }\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    int num = 0;\n    if (num == 0) {\n        printf(\"Zero\\n\");\n    }\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    int num = -5;\n    if (num < 0) {\n        printf(\"Negative number\\n\");\n    }\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    if (num % 2 == 0) {\n        printf(\"Even number\\n\");\n    }\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    int num = 9;\n    if (num % 2 != 0) {\n        printf(\"Odd number\\n\");\n    }\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Functions",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nvoid greet() {\n    printf(\"Hello, World!\\n\");\n}\n\nint main() {\n    greet();\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint add(int a, int b) {\n    return a + b;\n}\n\nint main() {\n    int sum = add(5, 3);\n    printf(\"Sum: %d\\n\", sum);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint factorial(int n) {\n    if (n == 0)\n        return 1;\n    else\n        return n * factorial(n - 1);\n}\n\nint main() {\n    int num = 5;\n    int fact = factorial(num);\n    printf(\"Factorial of %d: %d\\n\", num, fact);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint square(int num) {\n    return num * num;\n}\n\nint main() {\n    int num = 4;\n    int result = square(num);\n    printf(\"Square of %d: %d\\n\", num, result);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint power(int base, int exponent) {\n    int result = 1;\n    while (exponent > 0) {\n        result *= base;\n        exponent--;\n    }\n    return result;\n}\n\nint main() {\n    int base = 2;\n    int exp = 5;\n    int result = power(base, exp);\n    printf(\"%d raised to the power of %d: %d\\n\", base, exp, result);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Arrays",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int numbers[5] = {1, 2, 3, 4, 5};\n    for (int i = 0; i < 5; i++) {\n        printf(\"%d\\n\", numbers[i]);\n    }\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    float grades[3] = {75.5, 80.0, 90.5};\n    for (int i = 0; i < 3; i++) {\n        printf(\"%.2f\\n\", grades[i]);\n    }\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    char message[10] = \"Hello\";\n    printf(\"Message: %s\\n\", message);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    int numbers[] = {1, 2, 3, 4, 5};\n    int sum = 0;\n    for (int i = 0; i < sizeof(numbers) / sizeof(numbers[0]); i++) {\n        sum += numbers[i];\n    }\n    printf(\"Sum: %d\\n\", sum);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    int matrix[3][3] = {\n        {1, 2, 3},\n        {4, 5, 6},\n        {7, 8, 9}\n    };\n    for (int i = 0; i < 3; i++) {\n        for (int j = 0; j < 3; j++) {\n            printf(\"%d \", matrix[i][j]);\n        }\n        printf(\"\\n\");\n    }\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Pointers",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    int *ptr = &num;\n    printf(\"Value: %d\\n\", *ptr);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    int numbers[] = {1, 2, 3, 4, 5};\n    int *ptr = numbers;\n    for (int i = 0; i < 5; i++) {\n        printf(\"%d\\n\", *ptr);\n        ptr++;\n    }\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nvoid swap(int *a, int *b) {\n    int temp = *a;\n    *a = *b;\n    *b = temp;\n}\n\nint main() {\n    int x = 10;\n    int y = 20;\n    printf(\"Before swap: x=%d, y=%d\\n\", x, y);\n    swap(&x, &y);\n    printf(\"After swap: x=%d, y=%d\\n\", x, y);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    int *ptr = &num;\n    printf(\"Address: %p\\n\", ptr);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    int num = 10;\n    int *ptr = &num;\n    printf(\"Address: %p\\n\", (void *)ptr);\n    printf(\"Value: %d\\n\", *ptr);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "Structures",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nstruct Person {\n    char name[20];\n    int age;\n};\n\nint main() {\n    struct Person p1;\n    strcpy(p1.name, \"John\");\n    p1.age = 25;\n    printf(\"Name: %s\\n\", p1.name);\n    printf(\"Age: %d\\n\", p1.age);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nstruct Point {\n    int x;\n    int y;\n};\n\nint main() {\n    struct Point p1 = {2, 3};\n    printf(\"Point: (%d, %d)\\n\", p1.x, p1.y);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nstruct Rectangle {\n    int length;\n    int width;\n};\n\nint main() {\n    struct Rectangle r1;\n    r1.length = 5;\n    r1.width = 3;\n    int area = r1.length * r1.width;\n    printf(\"Area: %d\\n\", area);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nstruct Student {\n    char name[20];\n    int rollNumber;\n};\n\nint main() {\n    struct Student s1 = {.name = \"Alice\", .rollNumber = 101};\n    printf(\"Name: %s\\n\", s1.name);\n    printf(\"Roll Number: %d\\n\", s1.rollNumber);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nstruct Circle {\n    float radius;\n};\n\nint main() {\n    struct Circle c1;\n    c1.radius = 3.14;\n    float area = 3.14 * c1.radius * c1.radius;\n    printf(\"Area: %.2f\\n\", area);\n    return 0;\n}"
        }
      ]
    },
    {
      "name": "File Handling",
      "examples": [
        {
          "pro1": "#include <stdio.h>\n\nint main() {\n    FILE *file = fopen(\"example.txt\", \"w\");\n    if (file == NULL) {\n        printf(\"File could not be opened.\\n\");\n        return 1;\n    }\n    fprintf(file, \"Hello, World!\\n\");\n    fclose(file);\n    return 0;\n}"
        },
        {
          "pro2": "#include <stdio.h>\n\nint main() {\n    FILE *file = fopen(\"example.txt\", \"r\");\n    if (file == NULL) {\n        printf(\"File could not be opened.\\n\");\n        return 1;\n    }\n    char message[100];\n    fgets(message, 100, file);\n    printf(\"Message: %s\\n\", message);\n    fclose(file);\n    return 0;\n}"
        },
        {
          "pro3": "#include <stdio.h>\n\nint main() {\n    FILE *file = fopen(\"numbers.txt\", \"w\");\n    if (file == NULL) {\n        printf(\"File could not be opened.\\n\");\n        return 1;\n    }\n    int numbers[] = {1, 2, 3, 4, 5};\n    for (int i = 0; i < 5; i++) {\n        fprintf(file, \"%d\\n\", numbers[i]);\n    }\n    fclose(file);\n    return 0;\n}"
        },
        {
          "pro4": "#include <stdio.h>\n\nint main() {\n    FILE *file = fopen(\"numbers.txt\", \"r\");\n    if (file == NULL) {\n        printf(\"File could not be opened.\\n\");\n        return 1;\n    }\n    int num;\n    while (fscanf(file, \"%d\", &num) != EOF) {\n        printf(\"%d\\n\", num);\n    }\n    fclose(file);\n    return 0;\n}"
        },
        {
          "pro5": "#include <stdio.h>\n\nint main() {\n    FILE *file = fopen(\"data.bin\", \"wb\");\n    if (file == NULL) {\n        printf(\"File could not be opened.\\n\");\n        return 1;\n    }\n    int numbers[] = {1, 2, 3, 4, 5};\n    fwrite(numbers, sizeof(int), 5, file);\n    fclose(file);\n    return 0;\n}"
        }
      ]
    }
  ]
}