Certainly! Here is an example program that demonstrates how to declare, initialize, and access an array in C:
#include <stdio.h>
int main(void) {
// Declare an array of integers with size 10
int array[10];
// Initialize the array with values
for (int i = 0; i < 10; i++) {
array[i] = i * i;
}
// Access and print the values of the array
for (int i = 0; i < 10; i++) {
printf("array[%d] = %d\n", i, array[i]);
}
return 0;
}
This program declares an array of integers called
array
with size 10, initializes the array with the squares of the numbers 0 through 9, and then prints the values of the array to the console.
0 Comments