Introduction to Arrays in C++

Hello Everyone!

In this tutorial, we will learn and understand the basics of the of Array data structure, in the C++ programming language.

Arrays in C++

In programing, arrays are reffered to as structured data types. An array is defined as finite ordered collection of homogenous data, stored in contiguous memory locations.

For developing better understanding of this concept, we will recommend you to visit: Arrays in C language, where we have discussed this concept in detail.

The below given commented code demonstrates the basics of the array data strcture in C++.


#include <iostream>
using namespace std;

int main()
    cout << "\n\nWelcome to Studytonight :-)\n\n\n";
    cout << " =====  Program to Understand the basics of an Array  ===== \n\n";

    //i to iterate the outer loop and j for the inner loop
    int i, n;

    cout << "\n\nEnter the number integers you want in an array: ";
    cin >> n;

    //Declaring an array containing 'n' integers
    int arr[n];

    cout << "\n\n Enter " << n << " integers into an array :\n\n";

    for (i = 0; i < n; i++)
        cin >> arr[i];

    cout << "\n\n The Elements of the Array are: \n\n";

    for (i = 0; i < n; i++)
        cout << " arr [ " << i << " ] = " << arr[i] << endl;

    cout << "\n\n";

    return 0;


C++ Intro to  example

We hope that this post helped you develop better understanding of the concept of the Array data structure in CPP. For any query, feel free to reach out to us via the comments section down below.

Keep Learning : )