Through this article we will be going to discuss about array of C in detail in which following topic are included
- What is an array in C language ?
- Syntax of an array in C
- How to declare an array in C ?
- How to initialise an array in C ?
- Example of array in C
What is an Array in C programming ?
An array in C programming is a collection same data type of elements or in other words we can say that it is collection of homogeneous elements of same data type.
Syntax of an Array in C:
data_type array_variable[size of array];
int main
{
char a[2];
char b[5];
char c[10];
}
- Size of an array is optional so, user can be define size of an array according to their needs.
- If you want to take an input from the user, you must be use loop for taking an input.
How to declare an array in C ?
data_type array_variable[size of array];
int main
{
char a[2];
char b[5];
char c[10];
}
Declaration and syntax both is about to same thing in C language so don't confuse in it
How to initialize an array in C ?
data_type array_name[indexed subscript]=
int main()
{
char a[3];
char a[0]=A;
char a[1]=B;
char a[2]=C;
}
Example of array in C
#include<stdio.h>
int main()
{
int i;
char a[26];
printf("Enter the characters");
for(i=0;i<26;i++)
scanf("%c",&a[i]);
printf("The element of array is");
for(i=0;i<26;i++)
printf("%c",a[i]);
return 0;
}
_____________________________________________________________
_____________________________Conclusion
In this article we have learned about array in C in detail with example and its syntax , I hope after reading this article you have no any doubt remaining in case of array, but still if you have any queries feel free ask below._________________________________________
Important link- One dimensional Array
- Two dimensional Array
- Multidimensional Array
- Advantage and Disadvantage of an Array

