Ticker

6/recent/ticker-posts

Difference between Structure and Array in C

Difference between Structure  and Array in C

Structure and Array both are very important data types of C programming language that are used for creating efficient programs. On one hand Structure allows grouping of different data types and on the other, Array provides the facility of creating sequence of similar datatype.

Some important differences between Structure and Array are as follows :

S.No. Structure Array
1
Structure is a user defined datatype.
Array is a derived datatype.
2
Structure can have members of different datatype.
Array members are always of similar datatype.
3
Structure gives  a flexibility of creating memory for different  datatype.
Array can store list of values or table of values of homogeneous datatype.
4
Nesting of Structure is possible.
Nesting of Array is not possible.
5
For declaring a Structure Struct keyword is used.
Arrays are declared using data types.
6
Ex:  Declaring a Structure with 3 members.
    struct book
        {
        char name [15];
        char author [15];
        float price ;
        int pages;
        };

Ex: Declaring an array of int type.

    int Arr [4]= {10,20,30,40};


Post a Comment

0 Comments