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

How many types of arrays are there in c?

790


How can you invoke another program from within a C program?

822


How can you be sure that a program follows the ANSI C standard?

1384


What is the purpose of realloc()?

889


What are header files and what are its uses in C programming?

862


What are the advantages of using Unions?

856


Can we declare function inside main?

766


Is main is a keyword in c?

860


Explain how do you generate random numbers in c?

826


i want to know the procedure of qualcomm for getting a job through offcampus

2208


What is sizeof in c?

772


Is it better to use malloc() or calloc()?

846


What is the purpose of type declarations?

889


What are 3 types of structures?

832


What is union and structure in c?

874