#include <stdio.h>
int main(void) {
// Declare an array of integers
int numbers[] = {1, 2, 3, 4, 5};
// Declare an array of pointers to integers
int *pointers[] = {&numbers[0], &numbers[1], &numbers[2], &numbers[3], &numbers[4]};
// Print the values of the integers using the pointers
for (int i = 0; i < 5; i++) {
printf("Value of numbers[%d]: %d\n", i, *pointers[i]);
}
return 0;
}
This program declares an array of integers called
numbers
and an array of pointers to integers called pointers
. It initializes the pointers
array with the addresses of the elements of the numbers
array. It then prints the values of the integers using the pointers in the pointers
array.Here is an example of the output of this program:
Value of numbers[0]: 1
Value of numbers[1]: 2
Value of numbers[2]: 3
Value of numbers[3]: 4
Value of numbers[4]: 5
0 Comments