# Difference Between One-Dimensional and Two-Dimensional Array

By BYJU'S Exam Prep

Updated on: September 25th, 2023

The Difference Between One-Dimensional and Two-Dimensional Array is that a one-dimensional array is a list of variables, all of which have the same data type. In contrast, a two-dimensional array is an ‘array of arrays’ all have similar data types. An array is a collection of variables with similar data types with a common name.

Difference Between One-Dimensional and Two-Dimensional Array PDF

First, this article shows the difference between one-dimensional and two-dimensional arrays. Thereafter, we discuss the functionality of the one-dimensional and two-dimensional arrays individually.

## Difference Between One-Dimensional and Two-Dimensional Array

Here, we will see the Difference Between One-Dimensional and Two-Dimensional Array and then discuss the functionality of the One-Dimensional and Two-Dimensional Array individually, which are important for the GATE CSE exam. The table below shows the Difference Between One-Dimensional and Two-Dimensional Array based on the declaration, type, etc.

Key Differences Between One-Dimensional and Two-Dimensional Arrays

 One-Dimensional Array Two-Dimensional Array Keep a single list of elements of the same data type in a one-dimensional array. ‘List of lists,’ array of arrays, or ‘array of one-dimensional arrays’ should be saved in the two-dimensional array. /*declaration in C++ type variable_name[ size ];*/ /*declaration in Java type variable_name [ ]; variable_name = new type[size]; */ /*declaration in C++ type variable_name[size1][size2]; */ /*declaration in Java type variable_name= new int[size1][size2]; */ In one dimensional array, Total Bytes = sizeof(datatype of array variable) * array size. In a two-dimensional array, Total Bytes= sizeof(array variable datatype)* size of first index* size of second index. It can be received as a pointer, sized array, or unsized array. The receiving parameter should define the array’s rightmost dimension. The one-dimensional array is a list that represents multiple data items. The two-dimensional array represents several data items in the form of a table with columns and rows.

## What is a One-Dimensional Array?

The one-dimensional array comprises a list of variables with the same data type. The one-dimensional array has a fixed size. In C++, we can use a vector to create a dynamically sized array. Various problems can be formulated based on this concept of the One-Dimensional Array in the GATE question paper. One-dimensional Array is declared in C++ as:

### Syntax of One-Dimensional Array

variable name[size] ;

The example of a one-dimensional array is as follows:

## What is a Two-Dimensional Array?

A two-dimensional array comprises a collection of arrays with similar data types. Multi-dimensional Arrays are another name for two-dimensional arrays. A matrix is another name for a two-dimensional array which is important for the GATE exam.

A two-dimensional array is declared in C++ as follows:

### Syntax of Two-Dimensional Array

type variable name[size1][size2];

All elements of a 2D array can be accessed both randomly and by index.

POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com