array loop in c

Here is an example of a loop that iterates over an array in C:

#include <stdio.h>

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    int size = sizeof(arr) / sizeof(arr[0]);

    for (int i = 0; i < size; i++) {
        printf("%d ", arr[i]);
    }

    return 0;
}

This code defines an integer array arr with 5 elements. The size variable is calculated by dividing the total size of the array by the size of a single element.

The for loop starts with i equal to 0 and iterates until i is less than size. In each iteration, it prints the value of arr[i] using the printf function.

After the loop finishes, the program returns 0. When you run this code, it will output the numbers 1, 2, 3, 4, and 5, each separated by a space.