Blogware Logo
Blogware
Home
Celebriware
Feedback
Need Help?
ImageSurajit Nandy
Published on : 2nd Oct 2021
Cover Image
Array in C programming
Why do we need array ?
When we have 1000 variables of same type, it is impossible do declare them one by one. For this, we need array.
Definition :
An array is a collection of similar types of elements. Array elements are stored in contiguous memory locations.
Array declaration :
We have to declare the type of array and dimension of array.
Example :
int arr[5];
Here, array data type is integer and dimension is 5.
Array declaration with initialization :
Syntax : int arr[5] = {10, 20, 30, 40, 50};
Indexing in array :
Array index starts with 0. arr[0] will give you 10. We can assign a value in an array cell like arr[0] = 11. Now the array is {11, 20, 30, 40, 50}.
Visualization of array :

Visualization of array
Source Code :
#include <stdio.h> int main(int argc, char** argv) { int arr[5] = {10, 20, 30, 40, 50}; arr[0] = 11; printf("Array elements :"); int i; for(i=0; i<5; i++) { printf(" %d", arr[i]); } return 0; }
Output :
Array elements : 11 20 30 40 50
CelebriwareProductsServicesAdvertisementInvestorsPrivacy PolicyTerms of Service
Blogware Logo
Copyright © 2025 Blogware. All rights reserved.