Multiple choice

void main() { int arr[4] = {1, 2,3, 4} int *ptr = &arr[0], i; for(i = 0; i < 2; i++) } What should be the statement in the blank to print all the elements in the array?

  1. printf(”%d “, *(ptr + i ));

  2. printf(”%d “, *(ptr)+ i );

  3. printf(”%d “, (ptr + i ));

  4. printf(”%d “, *(ptr ));

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To print array elements using a pointer, *(ptr + i) correctly dereferences the pointer offset by i.