Creating an Array

In this chapter, you will see the use of arrays in C++.

Introduction

An array is a collection of elements of the same data type a the single name. Let’s see how we can declare and initialize an array in C++.

Array declaration

The general syntax for declaring an array is given below:

In the array declaration, we specify the data type followed by an array name, which is then followed by an array size in square brackets.

See the code given below!

Press + to interact
#include <iostream>
using namespace std;
int main() {
int Roll_Number[5];
}

We declare an array Roll_Number that can store 5 integer ...