Skip to main content

Posts

Showing posts with the label Array in C with Example

Array in C Language with Example

In C, an array is a collection of elements of the same data type that are stored in contiguous memory locations. Arrays provide a convenient way to store and access multiple values using a single variable name. Here's an example of working with arrays in C: ```c #include <stdio.h> int main() {     // Declaration and initialization of an integer array     int numbers[5] = {10, 20, 30, 40, 50};     // Accessing array elements     printf("The third element is: %d\n", numbers[2]);     // Modifying array elements     numbers[1] = 25;     printf("Modified second element: %d\n", numbers[1]);     // Iterating over array elements     printf("All array elements: ");     for (int i = 0; i < 5; i++) {         printf("%d ", numbers[i]);     }     printf("\n");     ...