Structural Data Types


Arrays


The C language provides a possibility to enable the user defining a set of ordered data items known as an array. Array can be understood as a number of memory locations, each of which can be referenced by the same variable name. Like any other variable arrays must be declared before they are used.
The general form of declaration is:
data_type array_name [size]
The number of square brackets defines the dimension of the array.

Example 1:
double 3d_coefficients[10][20][30];
This array is a 3 dimensional array for double type elements

Example 2:
int semester[6]={0};
This array is a one dimensional array filled with zeros

Example 3:
data[3][4]=5;
The record above is a reference to a specific cell in the array and a value assignment to it.

Example 4:
char word[]=”hello”;
The easiest example of an array can be a string type, which is one-dimensional array containing a sequence of characters.


Struct


struct - is a complex data type that aggregates a fixed set of labelled objects, possibly of different types, into a single object. A struct declaration consists of a list of fields, each of which can have any type.

Example of declaration:
struct employee {

char name [20];
char surname [20];
int age;
char position [30];
}