Skip to Main Content






C++ programming language

Arrays

An array is a sequence of values stored in one variable.

int values[5] = {1, 4, 7, 9, 8};
  • First method: In first method you declare the array and assign values in the same line of code.
datatype array_name [ array_size ] = {values};
  • Second method : in the second method you declare the array first and then you can assign the values to its elements. An easier assignment of values can be within for loops.
datatype array_name [ array_size ];

//then you assign values in another line of the code

array_name [ element]= value;

Multidimensional arrays

A multidimensional array is an array inside another array. You can think about it as a table that has rows and columns.

int table [2] [3] = { {2,5,6} , {4,7,8} };

How to create a multidimensional array?

 

How to print a multidimensional array using for loops?