Home / General Knowledge / Testing New :: Discussion

Discussion :: Testing New

  1. Find the output of the following program.

    void main()

    {

    int array[10];

    int *i = &array[2], *j = &array[5];

    int diff = j-i;

    printf("%d", diff);

    }

  2. A.

     3

    B.

     6

    C.

     Garbage value

    D.

     Error

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    When subtracting pointers you get the number of elements between those addresses, not the number of bytes.


Be The First To Comment