print arrays cpp code example
Example 1: c++ print every element in array
#include<iostream>
int main()
{
int array[8] = {1,2,3,4,5,6,7,8};
int i = 0;
while (i <= sizeof(array)/sizeof(int))
{
std::cout << array[i];
i++;
}
}
Example 2: take input from user in array c++
// declare and initialize an array without defining size
int x[] = {19, 10, 8, 17, 9, 15};