#include <stdio.h>
#include <omp.h>

int main() {
    int n = 10; 
    int a[n], b[n], c[n];

    // Initialize arrays
    for (int i = 0; i < n; ++i) {
        a[i] = i;
        b[i] = i * 2;
    }

    // Work sharing with parallel for
    #pragma omp parallel for
    for (int i = 0; i < n; ++i) {
        c[i] = a[i] + b[i]; 
    }

    printf("Vector Addition using parallel for:\n");
    for (int i = 0; i < n; ++i) {
        printf("c[%d] = %d\n", i, c[i]);
    }

    // Work sharing with sections
    #pragma omp parallel sections
    {
        #pragma omp section 
        {
            for (int i = 0; i < n/2; ++i) {
                c[i] *= 2; 
            }
        }
        #pragma omp section 
        {
            for (int i = n/2; i < n; ++i) {
                c[i] *= 3; 
            }
        }
    }

    printf("\nVector Modification using sections:\n");
    for (int i = 0; i < n; ++i) {
        printf("c[%d] = %d\n", i, c[i]);
    }

    return 0;
}