what is difference between array and structure?

Answer Posted / shweta

Both arrays and structures are classified as structured data
type as provide a mechanism that enables us to access and
manipulate data in relatively easy manner. but they differ
in number of ways:-
1)An array is a collection of related data elements of same
type. Structure can have elements of different types.
2. An array is derived data type whereas a structure is a
programmer defined one.
3) An array behaves like a built in data types only we need
to declare it.but in case of structures , first we have to
design and declare a data structure before the variables of
that type are declared and used.


example:of array:

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];//only declare an array variable




example of structure:
struct book_bank
{
char title[5];
char author[3];
int pages;
float price;
};// this format of defining is also known as TEMPLATE
struct book_bank book1, book2;// declaration of variable

Is This Answer Correct ?    48 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are structure types in C?

664


How can I make it pause before closing the program output window?

579


What is main () in c?

584


Explain a pre-processor and its advantages.

630


How can I manipulate individual bits?

606






What is wild pointer in c with example?

573


develop algorithms to add polynomials (i) in one variable

1738


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

578


What is a stream?

645


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

651


How can I pad a string to a known length?

610


What does 4d mean in c?

945


What is dynamic dispatch in c++?

554


What are the different types of control structures in programming?

658


What is main () in c language?

592