C Language - Structures,Unions
You Are Here :: Home > C Language > Structures,Unions General Questions
25. | union test {
int x;
char arr[4];
int y;
};
int main()
{
union test t;
t.x = 0;
t.arr[1] = 'G';
printf("%s ", t.arr);
return 0;
}
Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
|
|||||||
|
26. | struct list { char *item;
struct list *next;
}
/* Here is the main program. */
main(argc, argv)
{ ... }
|
|||||||
|
27. | What will be the output of the program ? #include
int main()
{
union var
{
int a, b;
};
union var v;
v.a=10;
v.b=20;
printf("%d\n", v.a);
return 0;
}
|
|||||||
|
28. | What is the output of this C code? #include
struct student
{
char *name;
};
void main()
{
struct student s, m;
s.name = "st";
m = s;
printf("%s%s", s.name, m.name);
}
|
|||||||
|
29. | What will be the output of the program ? #include
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
return 0;
}
|
|||||||
|
30. | Comment on the following union declaration? #include
union temp
{
int a;
float b;
char c;
};
union temp s = {1,2.5,'A'}; //REF LINE
Which member of the union will be active after REF LINE?
|
|||||||
|
« previous
1
2
3
4
5
6
7
8
9
...next »