Answers for "print the elements of the array without using the [] notation in c++"

C++
0

print the elements of the array without using the [] notation in c++

#include <iostream>
using namespace std;

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

    for (int i = 0; i < size; i++)
    {
        cout << *(arr + i) << "  "; // prints.. 2  4  8.
    }
}
Posted by: Guest on February-15-2021

Code answers related to "print the elements of the array without using the [] notation in c++"

Browse Popular Code Answers by Language