Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is difference between array,strutter,union and pointers

Answer Posted / ravi

structure is collection of different data types.
union is same as the structures, the only difference is in
memory allocation.
struct
{
int a;
float b;
};
struct s;
s.a=10;
s.b=3.0;
printf("%d%f",s.a,s.b);

For the above structure it allocates 2bytes for integer
variable and 4 bytes for flaot variable. so totally it
allocates 6bytes of memory to that structure. we can print
the s.a and s.b values as 10 and 3.0
#include<stdio.h>
union
{
int a;
char ch;
}u;

u.a=100;
u.ch='a';
printf("%d\n%d",u.a,u.ch);


But incase of union, the memory allocated is maximum
memory required among the variables. so only 4 bytes is
allocated to unions.
if u try to print the u.a, u.ch values it prints 97, 97
where the value of u.a is being assigned by u.ch . so we
cannt get value of u.a at last. It wont happen incase of
structures. so mostly we use structures in programming.

Is This Answer Correct ?    31 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is a house a mass structure?

1052


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

1093


What is the difference between array and pointer in c?

1090


What are the application of void data type in c?

1133


Explain is it valid to address one element beyond the end of an array?

1148


What is c language used for?

923


What is difference between far and near pointers?

986


What is bubble sort technique in c?

932


How many header files are in c?

983


Which is better oop or procedural?

988


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

1023


What is the use of putchar function?

1008


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...

1861


How can you increase the allowable number of simultaneously open files?

1090


What is difference between && and & in c?

1045