Answers for "how do you display each array element’s value and address byusing the pointer as if it were an array."

C
1

accessing elements of 1d array using pointers

#include<stdio.h>

int main(){

    int arr[] = {1,3,4,5,6,7,8};
    int *ptr = &arr; //storing address of the first element in array in the ptr

  	//accessing the elements of the array using ptr
    for(int i=0;i<7;i++)
        printf("%d ",*(ptr+i));
  	//here i represents the value to be added to the base address
    return 0;
}
Posted by: Guest on June-18-2020

Code answers related to "how do you display each array element’s value and address byusing the pointer as if it were an array."

Code answers related to "C"

Browse Popular Code Answers by Language