Homework Solution: Consider the following C code fragment:…

    Consider the following C code fragment: int arr[20][30]; int &arr[3][29]: The expression *(ptr + 4) is equivalent to arr[ ? ][ ? ]. Use values that are within the range of their corresponding dimensions in the declaration of the array.

    Expert Answer

     
    #include <stdio.h>

    Consider the subjoined C adjudication fragment:

    int arr[20][30];

    int &arr[3][29]:

    The indication *(ptr + 4) is equiponderant to arr[ ? ][ ? ].

    Use values that are among the place of their identical work in the assertion of the accoutre.

    Expert Acceptance

     

    #include <stdio.h>
    #include <stdlib.h>

    int ocean()
    {
    int arr[20][30];

    printf(“Start of accoutre: %pn”, &arr);
    printf(“pointer+4: %pn”, &arr+4);
    printf(“pointer arr[0][4]: %pn”, &arr[0][4]);

    void *mem1 = &arr+4;
    void *mem2;

    for (int i = 0; i < 1000; ++i) {
    for (int j = 0; j < 1000; ++j) {
    if (mem1 == &arr[i][j]) {
    printf(“i = %i, j = %in”, i, j);
    printf(“mem residuum 1 = %p, mem residuum 2 = %pn”, mem1, &arr[i][j]);
    exit(0);
    }
    }
    }

    // The indication *(ptr + 4) is equiponderant to arr[ 47 ][ 990 ].

    return 0;
    }

    Output:

    acceptance if arr[47][990]