61. Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?
(Assume: struct temp{int a;}s;)
(Assume: struct temp{int a;}s;)
62. What will be the output of the following C code?
#include <stdio.h>
struct student
{
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
#include <stdio.h>
struct student
{
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
63. What will be the output of the following C code?
#include <stdio.h>
struct point
{
int x;
int y;
} p[] = {1, 2, 3, 4, 5};
void foo(struct point*);
int main()
{
foo(p);
}
void foo(struct point p[])
{
printf("%d %d\n", p->x, p[2].y);
}
#include <stdio.h>
struct point
{
int x;
int y;
} p[] = {1, 2, 3, 4, 5};
void foo(struct point*);
int main()
{
foo(p);
}
void foo(struct point p[])
{
printf("%d %d\n", p->x, p[2].y);
}
64. Which of the following is not possible under any scenario?
65. Calculate the % of memory saved when bit-fields are used for the following C structure as compared to with-out use of bit-fields for the same structure? (Assuming size of int = 4)
struct temp
{
int a : 1;
int b : 2;
int c : 4;
int d : 4;
}s;
struct temp
{
int a : 1;
int b : 2;
int c : 4;
int d : 4;
}s;
66. What will be the output of the following C code?
#include <stdio.h>
typedef struct student
{
char *a;
}stu;
void main()
{
struct stu s;
s.a = "hi";
printf("%s", s.a);
}
#include <stdio.h>
typedef struct student
{
char *a;
}stu;
void main()
{
struct stu s;
s.a = "hi";
printf("%s", s.a);
}
67. What will be the output of the following C code?
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
68. Which of the following statement is true?
69. What will be the output of the following C code?
#include <stdio.h>
union u
{
struct p
{
unsigned char x : 2;
unsigned int y : 2;
};
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
#include <stdio.h>
union u
{
struct p
{
unsigned char x : 2;
unsigned int y : 2;
};
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
70. Which of the given option is the correct method for initialization?
typedef char *string;
typedef char *string;
Read More Section(Structure and Union)
Each Section contains maximum 100 MCQs question on Structure and Union. To get more questions visit other sections.