hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    In C program, how is the 4th element in an array accessed based on pointer notation?
    Question

    In C program, how is the 4th element in an array accessed based on pointer notation?

    A.

    *a+4

    B.

    *(a+4)

    C.

    * (*a+4)

    D.

    &(a+4)

    Correct option is B


    To access the 4th element of an array using pointer notation, consider the following:
    1 An array a[] can be represented using pointers, where the name of the array a acts as a pointer to the first element.
    · a is equivalent to &a[0], the address of the first element in the array.
    2 To access the 4th element of the array, we use the formula:
    4 th element =*(a+3)
    Here, a+3 points to the address of the 4th element (index 3 in zero-based indexing), and the dereference operator (*) retrieves the value stored at that address.
    *(a+4) This moves the pointer 4 positions ahead (to the 4th element) and dereferences it to get the value.

    test-prime-package

    Access ‘ISRO Electrical Engineering’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    354k+ students have already unlocked exclusive benefits with Test Prime!
    test-prime-package

    Access ‘ISRO Electrical Engineering’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    354k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow