---
title: "Array  in c++"  
description: "In this blog, I’m explaining about Array in c++   An array  is a data structure  that contains a group  of elements. Typically  these elements are all"  
author: "priyanka kushwaha"  
published: 2015-01-30  
updated: 2015-01-30  
canonical: https://www.mindstick.com/blog/745/array-in-c-plus-plus  
category: "visual c++"  
tags: ["array"]  
reading_time: 2 minutes  

---

# Array  in c++

In this blog, I’m explaining about [Array in c](https://answers.mindstick.com/qa/104685/what-is-an-array-in-c)++

\
An array is a [data structure](https://www.mindstick.com/blog/11221/simple-way-to-learn-dynamic-data-structure-in-c-language) that contains a group of [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements). Typically these elements are all of the same data type, such as an [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) or [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp).

##### Types of array

Single dimensional array

Multi dimensional array

##### Single dimensional array

The single dimensional array is the simplest array that contains only one row for storing data. It has single set of square bracket (“[]”).

##### Example

```
 #include "stdafx.h"#include<iostream>using namespace std;using namespace System; int main(array<System::String ^> ^args){             int size;            cout<<"Enter the size of array";            cin>>size;            int arr[100];            for (int i = 0; i < size; i++)            {                        cout<<"Enter a  no.";                        cin>>arr[i];            }              for (int i = 0; i <size; i++)            {                        int temp=0;                        for(int j=i+1;j<size;j++)                        {                        if(arr[i]>arr[j])                        {                                    temp=arr[i];                                    arr[i]=arr[j];                                    arr[j]=temp;                        }                        }                        }                        cout<<"Numbers in sorted order";            for(int i=0;i<size;i++)                        cout<<arr[i]<<endl;           Console::ReadKey(0);   }
```

##### Multi dimensional array

The multi dimensional [array contains](https://www.mindstick.com/forum/23089/in-java-how-can-i-test-if-an-array-contains-a-certain-value) more than one row to [store](https://www.mindstick.com/articles/13125/tips-to-increase-sales-of-your-woocommerce-store) data on it. It can be two dimensional array or three dimensional array or more.

##### Example:

```
 int main(array<System::String ^> ^args){                         //Declaring  multi dimensional  array            char arr1[3][4];             cout<<endl;            cout<<"\n Enter element for Row and column";            for(int i=0;i<3;i++)            {                        for(int j=0;j<3;j++)                        {                                                                        cin>>arr1[i][j];                        }            }            cout<<"\n All  the element of  array  is:\n";            for (int i = 0; i <3; i++)            {                        cout<<i+1;                        for (int j = 0; j< 3; j++)                        {                                    cout<<arr1[i][j];                        }                        cout<<endl;            }             Console::ReadKey(0);   }
```

---

Original Source: https://www.mindstick.com/blog/745/array-in-c-plus-plus

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
