belongs to collection: C language Pointer Exercises
I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
#include <stdio.h> int main() { int arr[10]; //declare integer array int *ptr; //declare an integer pointer int i; ptr=&arr[0]; //assign base address of array printf("Enter array elements:\n"); for(i=0;i < 5; i++){ scanf("%d",ptr+i); //reading through pointer } printf("\nEntered array elements are:"); printf("\nAddress\t\tValue\n"); for(i=0;i<5;i++){ printf("%08X\t%03d\n",(ptr+i),*(ptr+i)); } return 0; }
Result:
Enter array elements:
21
22
23
24
25
Entered array elements are:
Address Value
FCB04730 021
FCB04734 022
FCB04738 023
FCB0473C 024
FCB04740 025
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
Result:
Enter array elements:
21
22
23
24
25
Entered array elements are:
Address Value
FCB04730 021
FCB04734 022
FCB04738 023
FCB0473C 024
FCB04740 025
need an explanation for this answer? contact us directly to get an explanation for this answer