IndiaBIX.com
Search

C Programming - Structures, Unions, Enums - Discussion

@ : Home > C Programming > Structures, Unions, Enums > General Questions - Discussion

Read more:

"The secret to creativity is knowing how to hide your sources."
- Albert Einstein
2. 

What is the similarity between a structure, union and enumeration?

[A]. All of them let you define new values
[B]. All of them let you define new data types
[C]. All of them let you define new pointers
[D]. All of them let you define new structures

Answer: Option

Explanation:

No answer description available for this question.


Runa said: (Tue, Jul 27, 2010 11:37:45 AM)    
 
Structures unions and enumeration is used to create a new datatyppe that holds all kinds of datatype that is it includesn a datatype that can hold int, float, char, array inside a user ndefined datatype.

Pradeep Bhupathi said: (Wed, Aug 25, 2010 02:42:30 PM)    
 
Array, pointer, structure, union, enum - These all are user defind data types in c language.

Lokeswari said: (Sun, Dec 5, 2010 12:13:57 PM)    
 
What is pointer?

Yamuna said: (Thu, Dec 9, 2010 08:11:33 AM)    
 
Since Structure,Union,Enum are all User defined data types so user can use new values...thus logic is simple.. :-)

Varun said: (Fri, Jan 7, 2011 02:06:36 PM)    
 
But what is the difference?

Lipsa said: (Tue, Feb 1, 2011 10:05:01 AM)    
 
I agree with the runa and the main difference is the structure allocate different memory location with the data types but union allocate one large memory location for their members.

Surya said: (Thu, Mar 10, 2011 12:58:25 AM)    
 
These are used to create a new data type that holds all data types.

Nagarjun said: (Thu, Mar 10, 2011 05:22:36 AM)    
 
S.I agree vtt the Lips .but Enumrated gives the different states of a variable
example;
Enum person
{
male,fmale;
}
where the person having 2 states male r female;

Devi said: (Fri, Mar 11, 2011 03:35:16 AM)    
 
Thanks for your explanation.

Ashish Moreshwar said: (Tue, Apr 12, 2011 01:12:05 AM)    
 
Question is the similarity between a structure, union and enumeration. I think These all are the user defined data type. That holds various types of other data types.

Sivaramakrishna said: (Fri, Sep 23, 2011 02:58:56 PM)    
 
But enum will store's integer constants only. How it can store all types of datatypes.

Prabhu said: (Sat, Sep 24, 2011 03:31:26 PM)    
 
What is union ?

Raju Naidu said: (Fri, Oct 28, 2011 12:41:36 PM)    
 
Structure,union,enum all are userdefined datatypes.

Let we take one senario for structure.

Suppose in my programm i've to take the 100 variables. If you want to define many variables of different datatype, instead of declaring all those variables individually just go through sructure.Just define the one structure and take all those variables into that structure.

Then if you want to access any variable, just take the structname and dot operator and variable name.then we can access those variables.

union also used for storing the different datatypes variables. But there is small difference between structure and union.i.e
In structures we can acess all those variables at a time because of they are sharing different memory locations.

But in unions whatever we declare in the union those all are sharing same memory that's why at a time we can access only one variable. enum also used for storing user defined variable

Ex: enum { married,divorced,unmarred}

By defaultley married is indexed by o,divorced is 1, unmarried is 2.

If you want to change this order you can change by using married=10 then divorced = 11, unmarried = 12.

Saravanan said: (Sun, Dec 4, 2011 11:37:58 PM)    
 
Nice Explanation raju.......

Vinaysan said: (Thu, Dec 8, 2011 11:27:43 PM)    
 
I agree with runs. He/she said very nice defnition. And one more is the main difference between structure and union is

Structures allocates diffrent memory locations.

Union allocates large memory.

Jithin James said: (Mon, Dec 19, 2011 11:47:46 AM)    
 
Can anyone explain more about Enum....plz

Reshmi Singh said: (Thu, Dec 22, 2011 04:44:01 PM)    
 
Nice explanation raju. Enum is basically used for storing different datatypes variables. It is follow indexes like{0, 1, 2, . }.

Rohit8421 said: (Fri, Jan 13, 2012 10:19:23 PM)    
 
I'm agree that structures and union are use to define new data type , but how enumeration is use to define new data type. it just internally store an integer value.

Senthil.J said: (Fri, Aug 10, 2012 11:28:43 AM)    
 
I agree with raju he have given a good explanation about these.

In short structures are used to share different memory locations for variable and union is used to allocate large memory for all variables.

Prem said: (Sun, Sep 2, 2012 01:17:48 PM)    
 
I think structure, union and enum - user defined data type.

Ravendra Patel said: (Wed, Sep 5, 2012 11:37:18 PM)    
 
The working of structure and union is the same but the difference is in their memory allocation. The size of an structure is the summation of his all the member's size while the size of a union is the same as his largest member's size.

Anu said: (Sat, Sep 8, 2012 07:58:48 PM)    
 
Difference between structure and union is that......

Structure
structure allocates individual memory to all the variables declared in the structure based on there data types

whereas.....

unions allocation the memory takes place based on the variable which occupies largest memory space based on there data type

for example

if in a union 2 variables with data types char and int are given then it allocates a memory of 4 byte in GCC since it occupies more space than char the same memory is shared for both of them

Priya said: (Wed, Sep 26, 2012 04:02:43 AM)    
 
Can any one explain differnce between struct and enum ?

Swapnil said: (Sat, Oct 6, 2012 05:00:52 PM)    
 
@Priya: In structure only collection of different type of variables which are binded in one unit but enum are they who allows us to assign a particular value from given set to variable.

ex:
enum days {MON=-1, TUE, WED, THU, FRI, SAT};

//This allows days to have val from MON,TUE, WED,THU,FRI,SAT
Whose vaule are from -1 to 4. As MON=-1,TUE=0.

Nithya said: (Thu, Dec 13, 2012 11:07:20 AM)    
 
These are the user defined data types. But enumeration only allocate in integer data types. Then how does is allocated for new data types for others?

Knp said: (Tue, Jan 29, 2013 11:50:54 AM)    
 
In short structures are used to share different memory locations for variable and union is used to allocate large memory for all variables.

Kamal said: (Mon, Mar 18, 2013 10:59:25 AM)    
 
What is linked list in programming on C?

Pooja said: (Mon, Mar 25, 2013 03:22:52 PM)    
 
Are structure & union just differ in tums of memory. Is there not any other difference.

Rj Kumar said: (Tue, Aug 20, 2013 12:53:36 PM)    
 
Because these are user defined data type that use to define another data type.

Nups said: (Thu, Oct 3, 2013 12:21:48 PM)    
 
Please tell the proper difference between structure and enum and then union and enum?

Mahesh said: (Sat, Oct 5, 2013 09:41:01 AM)    
 
Hi, what is an array?

Murty Svvsn said: (Tue, Oct 22, 2013 11:44:11 PM)    
 
An array holds a collection related data items that are all belongs to one particular data type, i.e a single name to all data items but the data items have different memory locations.

Ex. datatype array_name[size];
int array[5];
float a[10];
char a[5];

so on...

Vivek said: (Sat, Oct 26, 2013 06:51:07 PM)    
 
Because these are user defined data type and each one contain own different data type collection.

Alex said: (Mon, Jan 27, 2014 06:47:22 PM)    
 
Can any one give an example of enum that contains different type of data-types ?

Saravanakumar said: (Sat, Jul 12, 2014 08:23:50 AM)    
 
How to store multiple data types in array?

Pradeep Kumar said: (Sun, Jul 13, 2014 02:47:03 PM)    
 
Use of structure we can use multiple data types in array.
We can define structure, union and enum.

STRUCTURE:
It is a user define data type that have we use define variable of different type of data type. it have allocate individual memory to all the variables declared in the structure based on there data types

UNION:
It is same as structure but memory allocation is maximum of there data type. In union variable have share these memory.

ENUM:
It have have declared different data type. the value of data type start with 0 by default.

Ex. enum={a,b,c,d};
Here initialize the value of
a=0
b=1
c=2
d=4

But enum={a=6,b,c,d}
Here initialize the value of
a=6
b=7
c=8
d=9

Write your comments here:
Name *:     Email:


© 2008-2014 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!