what is difference between array and structure?

Answer Posted / vinay

Array -
* Memory (array size) is fixed
* Accessing an element in array takes constant time. E.g. -
5th element in an array can be accessed as array[4] i.e.
searching/accessing an element in array takes comparatively
less time than in structures.
* Adding/deleting an element in the array is comparatively
difficult since the data already present in the array needs
to be moved
Structure -
* Memory (structure size) can be changed dynamically
* Accessing an element in a list takes more time
comparatively since we need to traverse thro the list
* Adding/deleting takes less time than in arrays

Is This Answer Correct ?    208 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream?

900


What is null pointer in c?

790


When the macros gets expanded?

1125


What are register variables? What are the advantage of using register variables?

931


what is the difference between class and unio?

2136


What is scope of variable in c?

807


What will the preprocessor do for a program?

804


What are the 5 elements of structure?

846


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

6325


How can I generate floating-point random numbers?

831


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2307


How important is structure in life?

839


Explain what is operator promotion?

871


What is wrong in this statement?

841


What are enums in c?

876