Home »
C programs »
C pointer programs
C program to read array elements and print the value with the addresses
By IncludeHelp Last updated : March 10, 2024
In this C program, we are reading 10 integer elements and printing array elements with the value and their addresses.
Program
/*C program to read array elements and print with addresses.*/
#include <stdio.h>
int main()
{
int arr[10]; //declare integer array
int *pa; //declare an integer pointer
int i;
pa=&arr[0]; //assign base address of array
printf("Enter array elements:\n");
for(i=0;i < 10; i++){
printf("Enter element %02d: ",i+1);
scanf("%d",pa+i); //reading through pointer
}
printf("\nEntered array elements are:");
printf("\nAddress\t\tValue\n");
for(i=0;i<10;i++){
printf("%08X\t%03d\n",(pa+i),*(pa+i));
}
return 0;
}
Output
Enter array elements:
Enter element 01: 11
Enter element 02: 23
Enter element 03: 444
Enter element 04: 4
Enter element 05: 5
Enter element 06: 6
Enter element 07: 77
Enter element 08: 89
Enter element 09: 67
Enter element 10: 12
Entered array elements are:
Address Value
E73BF180 011
E73BF184 023
E73BF188 444
E73BF18C 004
E73BF190 005
E73BF194 006
E73BF198 077
E73BF19C 089
E73BF1A0 067
E73BF1A4 012
C Pointer Programs »