One Dimensional Array in C
What is One Dimensional Array in C ?
An array of single or one dimension is known as a single dimensional array or 1-D array.
Single or one dimensional array can be of int,char,float etc.. type.
Syntax to declare an array
data_type arrayName[arraysize];
This is called a single-dimensional array. The arraySize must be an integer constant greater than zero and type can be any valid C data type. For example, to declare a 5-element array called num of type int, use this statement:
int num[5];
Now num is available array which is sufficient to hold upto 5 integer numbers.
Example 1
Output
10
20
30
40
50
20
30
40
50
Example 2
Output
Enter marks 50
Enter marks60
Enter marks70
Enter marks80
Enter marks90
Marks are 50
Marks are 60
Marks are 70
Marks are 80
Marks are 90
Example 3
Output
Marks are 10
Marks are 20
Marks are 30
Marks are 40
Marks are 50