
- C - Home
- C - Overview
- C - Features
- C - History
- C - Standards
- C - Environment Setup
- C - Program Structure
- C - Hello World
- C - Compilation Process
- C - Comments
- C - Basic Syntax
- C - User Input
- C - printf Function
- C - Format Specifiers
- Lexical Elements in C
- C - Tokens
- C - Keywords
- C - Identifiers
- Variables and Constants
- C - Variables
- C - Constants
- C - Const Qualifier
- C - Linkage
- Data Types and Type Conversions
- C - Data Types
- C - Literals
- C - Escape Sequences
- C - Booleans
- C - Integer Promotions
- C - Character Arithmetic
- C - Type Conversion
- C - Type Casting
- Operators in C
- C - Operators
- C - Arithmetic Operators
- C - Unary Operators
- C - Relational Operators
- C - Logical Operators
- C - Bitwise Operators
- C - Assignment Operators
- C - Increment and Decrement Operators
- C - Ternary Operator
- C - sizeof Operator
- C - Operator Precedence
- C - Miscellaneous Operators
- Decision Making & Control Statements
- C - Decision Making
- C - if Statement
- C - if...else Statement
- C - if...else if Ladder
- C - Nested if Statements
- C - Switch Statement
- C - Nested Switch Statements
- C - Switch Case Using Range
- Loops in C
- C - Loops
- C - For Loop
- C - While Loop
- C - Do...while Loop
- C - For Loop vs While Loop
- C - Nested Loop
- C - Infinite Loop
- C - Break Statement
- C - Continue Statement
- C - Goto Statement
- Functions in C
- C - Functions
- C - Function Prototype
- C - Main Function
- C - Function call by Value
- C - Function call by reference
- C - Nested Functions
- C - Variadic Functions
- C - User-Defined Functions
- C - Callback Function
- C - Return Statement
- C - Recursion
- C - Predefined Identifier __func__
- Scope Rules in C
- C - Scope Rules
- C - Static Variables
- C - Global Variables
- Arrays in C
- C - Arrays
- C - Properties of Array
- C - Multi-Dimensional Arrays
- C - Passing Arrays to Function
- C - Return Array from Function
- C - Variable Length Arrays
- C - Dynamic Arrays
- Strings in C
- C - Strings
- C - Array of Strings
- C - Character Arrays
- C - Special Characters
- Pointers in C
- C - Pointers
- C - Initialization of Pointer Arrays
- C - Applications of Pointers
- C - Dereference Pointer
- C - NULL Pointer
- C - void Pointer
- C - Const Pointers & Pointer to Const
- C - Dangling Pointers
- C - Pointer Arithmetics
- C - Pointers and Arrays
- C - Pointer vs Array
- C - Pointer to an Array
- C - Array of Pointers
- C - Pointers vs. Multi-dimensional Arrays
- C - Pointer to Pointer
- C - Chain of Pointers
- C - Character Pointers and Functions
- C - Passing Pointers to Functions
- C - Return Pointer from Functions
- C - Function Pointers
- C - Array of Function Pointers
- C - Pointers to Structures
- C - Near, Far and Huge Pointers
- C - Restrict Keyword
- User-Defined Data Types
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Self-Referential Structures
- C - Dot (.) Operator
- C - Lookup Tables
- C - Enumeration (or enum)
- C - Structure Padding and Packing
- C - Nested Structures
- C - Anonymous Structure and Union
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Flexible Array Members in Structures
- C - Structures vs Unions
- Memory Management in C
- C - Memory Layout
- C - Memory Management
- C - Memory Address
- C - Storage Classes
- C - Dynamic Array Resizing
- C - Memory Leaks
- File Handling in C
- C - File Handling
- C - Input & Output
- C - File Operations
- C - Formatted Output
- C - getc, getchar, getch, getche
- Preprocessors in C
- C - Preprocessors
- C - Pragmas
- C - Macros
- C - Working of Preprocessor
- C - Preprocessor Operators
- C - Header Files
- C - Custom Header Files
- Miscellaneous Topics
- C - Error Handling
- C - Variable Arguments
- C - Command Execution
- C - Math Functions
- C - Static Keyword
- C - Random Number Generation
- C - Command Line Arguments
- C Programming Resources
- C - Questions & Answers
- C - Quick Guide
- C - Cheat Sheet
- C - Useful Resources
- C - Discussion
- C - Online Compiler
C - Properties of Array
Arrays are a very important data structure in C. Use of array in C program makes it easier to handle large amount of data. Arrays have a number of advantages over singular variables as a result of their number of properties. Most of the important properties of array are a result of its composition − that an array is a collection of values of same data type, and in a continuous block of memory.
Array properties may change in the different programming languages. In C programming language, the following are the main properties of arrays:
- Collection of Same Data Type
- Contiguous Memory Allocation
- Fixed Size
- Length Depends on Type
- Indexing
- Pointer Relationship
- Lower and Upper Bounds
- Multi-dimensional Array
- Implementation of Complex Data Structures
Let us discuss each property in detail.
Collection of Same Data Type
All elements of an array must be of the same data type. This ensures consistent access and operations on the data.
If an array is declared as follows −
int arr[] = {50, 67.55, "hello", 21};
Compiler issues a warning −
initialization of 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]|
Contiguous Memory Allocation
All elements of an array are stored in contiguous memory locations, meaning they occupy a block of memory next to each other. This allows for efficient random access and memory management.

Fixed Size
The size of an array is fixed at the time of declaration and cannot be changed during the program's execution. This means you need to know the maximum number of elements you need beforehand. In C, an array cannot have a size defined in terms of a variable.
//This is accepted
#define SIZE = 10 int arr[SIZE];
//This is also accepted
const SIZE = 10; int arr[SIZE];
//This is not accepted
int SIZE = 10; int arr[SIZE];
//The size must be an integer. This will give error
float num[10.5] = {50, 55, 67, 73, 45, 21, 39, 70, 49, 51};
Length Depends on Type
Since an array can store all the elements of same type, the total memory occupied by it depends on the data type.
Example
#include<stdio.h> int main() { int num[10] = {50, 55, 67, 73, 45, 21, 39, 70, 49, 51}; int size = sizeof(num) / sizeof(int); printf("element at lower bound num[0]: %d \n", num[0]); printf("at upper bound: %d byte \n", num[size-1]); printf("length of int array: %ld \n", sizeof(num)); double nm[10] = {50, 55, 67, 73, 45, 21, 39, 70, 49, 51}; size = sizeof(nm) / sizeof(double); printf("element at lower bound nm[0]: %f \n", nm[0]); printf("element at upper bound: %f \n", nm[size-1]); printf("byte length of double array: %ld \n", sizeof(nm)); return 0; }
Output
element at lower bound num[0]: 50 at upper bound: 51 byte length of int array: 40 element at lower bound nm[0]: 50.000000 element at upper bound: 51.000000 byte length of double array: 80
Indexing
Each element in an array has a unique index, starting from 0. You can access individual elements using their index within square brackets. Usually, array is traversed with a for loop running over its length and using the loop variable as the index.
Example
#include <stdio.h> int main() { int a[] = {1,2,3,4,5}; int i; for (i=0; i<4; i++){ printf("a[%d]: %d \n", i, a[i]); } return 0; }
Pointer Relationship
The name of an array is equivalent to a constant pointer to its first element. This lets you use array names and pointers interchangeably in certain contexts.
Example
#include <stdio.h> int main() { int num[10] = {50, 55, 67, 73, 45, 21, 39, 70, 49, 51}; printf("num[0]: %d Address of 0th element: %d\n", num[0], &num[0]); printf("Address of array: %d", num); return 0; }
Output
num[0]: 50 Address of 0th element: 6422000 Address of array: 6422000
Lower and Upper Bounds
Each element in an array is identified by an index starting with 0. The lower bound of and array is the index of its first element, which is always 0. The last element in the array size -1 as its index.
Example
#include <stdio.h> int main() { int num[10] = {50, 55, 67, 73, 45, 21, 39, 70, 49, 51}; int size = sizeof(num) / sizeof(int); printf("element at lower bound num[0]: %d at upper bound: %d Size of array: %d", num[0], num[size-1], size); return 0; }
Output
element at lower bound num[0]: 50 at upper bound: 51 Size of array: 10
Multi-dimensional Array
The array is declared with one value of size in square brackets , it is called one dimensional array. In a one dimensional array, each element is identified by its index or subscript. In C, you can declare with more indices to simulate a two, three or multidimensional array.
Example
For example, following is the example of a two−dimensional array −
int a[3][3] = { {1, 2, 3}, {11, 22, 33}, {111, 222, 333}};
You can think of a one dimensional array as a list, and a two dimensional array as a table or a matrix. Theoretically, there is no limit to the number of dimensions of an array, but in practice, two−dimensional arrays are used in design of spreadsheets, databases etc.
Implementation of Complex Data Structures
We can use an array in the construction of a struct data type to implement data structures such as stack, linked list and trees.
Example
typedef struct stack { int top; int arr[10]; } Stack;
Thus, array is an important tool in the armoury of the programmer, as it can be used for different applications. The concept of array in C is implemented by many subsequent programming languages such as C++, C#, Java etc.