Example(s):Palindrome, prime, armstrong, "linear search", reverse etc.
Example(s):1575, 1632, 1539 (Only one at a time)
Login
[lwa]
Q&A
#5366
Question:
Write the main differences between structure and array
Answer:
Based on declaration concept: A structure is basically a template of variable/object to be declared in future while array is by itself a collection of variables of same type given a common name.
Based on data type: A structure can contain variables of different data types, while an array can have variables of same data type only.
Based on initial values: A structure can not have initial values of variables declared in it while array members can have initial values. In case of structures initial values can only be given only when its object is declared.
Based on memory required: Structure does not occupy memory space unless its object is declared. An array occupies memory space as soon as it is declared.
Based on instantiation: A structure can have multiple instances of same template. An array is not designed for instantiation.