### Arrays: The Basics

An array is an indexed group of data storage locations that have the same name and are distinguished from each other by a subscript, or index—a number following the variable name, enclosed in brackets. (This will become clearer as you continue.) Like other C variables, arrays must be declared. An array declaration includes both the data type and the size of the array (the number of elements in the array). For example, the following statarray named data that is type int and has 1,000 elements:

A multidimensional array has more than one subscript. A two-dimensional array has two subscripts, a three-dimensional array has three subscripts, and so on. There is no limit to the number of dimensions a C array can have. (There is a limit on total array size, as discussed later in today’s lesson.)

### Arrays

1) 1-Dimensional Array

2) 2-Dimensional Array

3) Multidimentional Array

int data[1000];

#### Code Example

#include<stdio.h> int main () { int array[10]; array[0] = 20; array[1] = 10; int sum = array[0] + array[1]; printf("Value is = %d", sum); return 0; }

### Output

Value is = 30

#### What is use of array in C?

Advertisements. **Arrays** a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An **array** is used to store a collection of data, but it is often more useful to think of an **array** as a collection of variables of the same type.

#### Why do we need array in C?

Main purpose of **array in C** programming language is to store multiple values of same datatype. explanation : … As well as variable ch can also store only one alphanumeric value. But in **array** if **we** declare **array** as a integer then **we** can store n number of integer type of value where n is index of **array** i. e. int arr[n];