Difference between Array and Union in C Last Updated : 02 Mar, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 1. Array in C : An array is collection of similar data items accessed by a common name stored at continuous memory locations. The elements of an array can be accessed using indices. They can be used to store primitive data types such as int, float, double, char, etc. but all elements have to be of the same data type. Below is the picturesque representation of an array. Declaration of an array : datatype array_name[size] 2. Union in C : Union is a user defined datatype that allows storage of heterogeneous elements in the same memory location. Size of the union is the size of the largest element in the union. Below is the picturesque representation of a union. Declaration of a union : union name { datatype element; datatype element; }; Difference between Array and Union : ARRAYUNIONCollection of elements of same data types.Collection of elements of heterogeneous data types.Arrays can be one or two dimensional.Unions do not have type.Each element is allocated a specific memory location.The elements share the memory location which has size equivalent to the size of the largest size element of the union.All members can contain value at a given time.Only one member can contain value at a given time.Not an efficient use of memory as all members are allocated different memory locations.Efficient use of memory as all members do not require separate memory location.Array elements can be accessed using index.The elements of a union cannot be accessed using index. Syntax : datatype array_name[size] Syntax : Union user defined name { datatype Variable 1; datatype variable2; }; Comment More infoAdvertise with us Next Article Swift - Difference Between Sets and Arrays A aktmishra143 Follow Improve Article Tags : Difference Between C Language Arrays C-Structure & Union C-Data Types +1 More Practice Tags : Arrays Similar Reads Difference between Structure and Array in C Array in C An array is collection of items stored at contiguous memory locations. Structure in C A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type. Difference between Structure and Array AR 2 min read Difference between Arrays and Pointers The array and pointers are derived data types that have lots of differences and similarities. In some cases, we can even use pointers in place of an array, and arrays automatically get converted to pointers when passed to a function. So, it is necessary to know about the differences between arrays a 7 min read Difference Between Structure and Union in C In C programming, both structures and unions are used to group different types of data under a single name, but they behave in different ways. The main difference lies in how they store data.The below table lists the primary differences between the C structures and unions:ParameterStructureUnionDefi 4 min read Difference between Stack and Array Stack: A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into a 3 min read Swift - Difference Between Sets and Arrays An array is a linear data structure which has contiguous memory in a single variable that can store N number of elements. For example, if we want to take 10 inputs from the user we canât initialise 10 variables. In this case you can make use of arrays. It can store N number of elements into a single 3 min read Difference between JOIN and UNION in SQL Pre-requisites: JOIN, UNION JOIN in SQL is used to combine data from many tables based on a matched condition between them. The data combined using the JOIN statement results in new columns. Consider the two tables: Boys Girls Example: sql> SELECT Boys.Name, Boys.Age, Girls.Address, FROM Boys INN 2 min read Like