Академический Документы
Профессиональный Документы
Культура Документы
car1-name,prize,color.
car2-name,prize,color.
similarly for 100 cars we have to do the same
you must thing for a array but it is of same datatype.
manager.age=27;
if manager.agr>30
manager.salary=55k;
else
mamager.salalry=66k
return manager.salary;
}
int main()
{
printf("%d",enter thensllary of e1 nd e2);
scanf("%d",&e1.salary,&e2.salary);
printf("%d",manager());
return 0;
}
#structure tag :-
struct employee{
char *name;
int age;
int salary;
}e1,e2;
int manager//function
{struct employee manager;
do;
}
int main()//function;
#typedef
}car;
int main()
{
struct car c1;
we can write it now as
car c1;
}
#initailizing and accessing the members of structure/////
#array of strucutre//////
struct car{char *name;
int age;
int salary;
};
int main()
{
struct car c[2];
int i;
for(i=0;i<=2;i++)
{
printf("enter the car %d",i+1);
scanf("%d",&c[i].name);
printf("enter the car %d",i+1);
scanf("%d",&c[i].age);
printf("enter the car %d",i+1);
scanf("%d",&c[i].salary);
}
printf("\n");
for(i=0;i<=2;i++)
{
printf //
print statment;;;;;;;---
}
######pointer to strcuture::::
struct abc{
int x;
int y;
};
int main()
{
struct abc a={0,1};
struct abc *ptr=&a;
printf("%d %d",ptr->x,ptr->y);//////////////////////ptr-> is equivalent to(*ptr).x
return 0;
}
######how memory is allocated to structure members---------
----when an object of some structure type is declared then some contiguous block of
memory will be allocated to strcuture members........
struct abc {
char a;
char b;
int d;
}
var;
//////////////////////size of var/////6 byte
structure padding :----- it is used to save the no of cycles of processor by using
structure padding.......
total size of var :---8bytes....
#####unions######
----union is a user defined datatype but unlike structures union members share same
memory loaction...........
eg:-
struct abc{
int a;
char b;
}vr;////having same different memory allocation
while in union same memory alloaction....