Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Difference Between Array and Stucture

Array
Structure
i. Data Collection     
Array is a collection of homogeneous data.
Stucture is a collection of heterogeneous data.
ii. Element Reference     
Array elements are referred by subscript.
Structure elements are referred by its unique name.
iii. Access Method     
Array elements are accessed by it's position or subscript.
Stucture elements are accessed by its object as '.' operator.
iv. Data type     
Array is a derived data type.
Structure is user defined data type.
v. Syntax     
<data_type> array_name[size];
struct struct_name
{
    structure element 1;
    structure element 2;
 ----------
 ----------
 structure element n;
}struct_var_nm;
vi. Example     
 int rno[5];
struct item_mst
{
    int rno;
    char nm[50];
}it;

Similer…..

HTTP And HTTPS

GET And POST


Difference Between Stucture and Union

Structure
Union
i. Access Members     
We can access all the members of structure at anytime.
Only one member of union can be accessed at anytime.
ii. Memory Allocation     
Memory is allocated for all variables.
Allocates memory for variable which variable require more memory.
iii. Initialization     
All members of structure can be initialized
Only the first member of a union can be initialized.
iv. Keyword     
'struct' keyword is used to declare structure.
'union' keyword is used to declare union.
v. Syntax     
struct struct_name
{
    structure element 1;
    structure element 2;
 ----------
 ----------
    structure element n;
}struct_var_nm;
union union_name
{
    union element 1;
    union element 2;
 ----------
 ----------
    union element n;
}union_var_nm;
vi. Example     
struct item_mst
{
    int rno;
    char nm[50];
}it;
union item_mst
{
    int rno;
    char nm[50];
}it;


Similer..........

HTTP And HTTPS

GET And POST