0 votes
89 views
in C programming by (98.9k points)
edited
Comparison between array and structure.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
Sr. No. Key Structure Array
1 Definition Structure can be defined as a data structure used as container which can hold variables of different types. On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.
2 Memory Allocation Memory allocation for input data in structure does not necessary to be in consecutive memory location. While in case of array the input data stored in contiguous memory allocation which implies that array stores data in such memory model where it assigns consecutive memory blocks (that is, memory blocks having consecutive addresses).
3 Accessibility In order to access the element in Structure we require to have the name of that element i.e it is mandatory to have element name for its retrieval from Structure. On other hand in case of Array we can access the element by index.
4 Pointer Structure do not have concept of Pointer internally. On other hand in case of Array it internally implements Pointer which always points to the first element of Array.
5 Instantiation Structure object can be created after declaration later in the program. On other hand in case of Array we can’t create its object after declaration.
6 DataType Structure supports multiple data-type variables as input. On other hand in case of Array we can’t have different data-type variable as input as it only supports same type data variables.
7 Performance Structure due to use defined data type become slow in performance as access and searching of element is slower in Structure as compare to Array. On other hand in case of Array access and searching of element is faster and hence better in performance.

 

Related questions

0 votes
1 answer 98 views
asked Jun 11, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 113 views
0 votes
1 answer 95 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

537 users

...