prints out the elements in the array c++

Code:

#include <iostream>
using namespace std;

int main() {
    int arr[] = {10, 20, 30, 40, 50};

    for (int i = 0; i < 5; i++) {
        cout << arr[i] << " ";
    }

    return 0;
}

Explanation: - The #include <iostream> directive includes the input/output stream library. - The using namespace std; statement allows elements of the standard C++ library to be accessed without the std:: prefix. - The main function is the entry point of the program. - An integer array arr is initialized with values {10, 20, 30, 40, 50}. - A for loop is used to iterate through the elements of the array. - Within the loop, each element of the array is printed using cout. - The loop iterates from i = 0 to i < 5, accessing each element of the array using arr[i]. - The return 0; statement signifies successful execution and termination of the program.