
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Arrays in C Language
Array is a collection of same type of elements at contiguous memory location. The lowest address corresponds to the first element while highest corresponds to last element.
Array index starts with zero(0) and ends with the size of array minus one(array size - 1). Array size must be integer greater than zero.
Let us see an example,
If array size = 10 First index of array = 0 Last index of array = array size - 1 = 10-1 = 9
Here is the syntax of arrays in C language,
type array_name[array_size ];
The following is how you can initialize an array.
type array_name[array_size] = { elements of array }
Here is an example of arrays in C language,
Example
#include <stdio.h> int main () { int a[5]; int i,j; for (i=0;i<5;i++) { a[i] = i+100; } for (j=0;j<5;j++) { printf("Element[%d] = %d
", j, a[j] ); } return 0; }
Output
Element[0] = 100 Element[1] = 101 Element[2] = 102 Element[3] = 103 Element[4] = 104
- Related Articles
- How to merge to arrays in C language?
- Post and Pre incremented of arrays in C language
- Explain the concepts of Pointers and arrays in C language
- Explain the characteristics and operations of arrays in C language
- How to perform the arithmetic operations on arrays in C language?
- How to swap two arrays without using temporary variable in C language?
- Arrays in C/C++?
- Strings in C Language
- kbhit in C language
- Multidimensional Arrays in C / C++
- Arrays in C/C++ program
- Explain C tokens in C Language
- Associative arrays in C++
- Sorted Arrays in C++
- Multidimensional Arrays in C

Advertisements