Structure And Union in C language MCQs

@T-Bone

This question paper focuses on the "Structure And Union" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

This question paper focuses on the "Structure And Union" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

Questions

1. Which of the following are themselves a collection of different data types?

Mark the correct option

2. Which operator connects the structure name to its member name?

Mark the correct option

3. Which of the following cannot be a structure member?

Mark the correct option

4. What is the correct syntax to declare a function foo() which receives an array of structure in function?

Mark the correct option

5. Union differs from structure in the following way

Mark the correct option

6. The size of the following union, where an int occupies 4 bytes of memory is union demo { float x; int y; char z[10]; };

Mark the correct option

7. Members of a union are accessed as________________.

Mark the correct option

8. It is not possible to create an array of pointer to structures.

Mark the correct option

9. Which of the following statement is True?

Mark the correct option

10. size of union is size of the longest element in the union

Mark the correct option

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

Mark the correct option

12. Which of the following share a similarity in syntax? 1. Union 2. Structure 3. Arrays 4. Pointers

Mark the correct option

13. Size of a union is determined by size of the.

Mark the correct option

14. Which operator connects the structure name to its member name?

Mark the correct option

15. How will you free the allocated memory ?

Mark the correct option

16. Which of the following accesses a variable in structure b?

Mark the correct option

17. Which of the following accesses a variable in structure *b?

Mark the correct option

18. Which of the following is a properly defined struct?

Mark the correct option

19. Which properly declares a variable of struct foo?

Mark the correct option

20. What is the output of this program? #include <stdio.h> struct test { int x = 0; char y = 'A'; }; int main() { struct test t; printf("%d, %c", s.x, s.y); return 0; }

Mark the correct option

21. What is the output of this program? #include <stdio.h> struct test { int x; char y; } test; int main() { test.x = 10; test.y = 'A'; printf("%d %c", test.x,test.y); return 0; }

Mark the correct option

22. What is the output of this program? #include <stdio.h> struct result{ char sub[20]; int marks; }; void main() { struct result res[] = { {"Maths",100}, {"Science",90}, {"English",85} }; printf("%s ", res[1].sub); printf("%d", (*(res+2)).marks); }

Mark the correct option

23. What will be the size of the following structure? struct demo{ int a; char b; float c; }

Mark the correct option

24. What is the output of this program? #include <stdio.h> void main() { struct demo{ char * a; int n; }; struct demo p = {"hello", 2015}; struct demo q = p; printf("%d", printf("%s",q.a)); }

Mark the correct option

25. What is the output of this program? #include <stdio.h> int main() { union demo { int x; int y; }; union demo a = 100; printf("%d %d",a.x,a.y); }

Mark the correct option

26. What is the output of this program? #include <stdio.h> int main() { enum days {MON=-1, TUE, WED=4, THU, FRI, SAT}; printf("%d, %d, %d, %d, %d, %d", MON, TUE, WED, THU, FRI, SAT); return 0; }

Mark the correct option

27. What is the output of this program? #include <stdio.h> int main(){ struct simp { int i = 6; char city[] = "chennai"; }; struct simp s1; printf("%d",s1.city); printf("%d", s1.i); return 0; }

Mark the correct option

28. What is the output of this program? #include <stdio.h> struct { int i; float ft; }decl; int main(){ decl.i = 4; decl.ft = 7.96623; printf("%d %.2f", decl.i, decl.ft); return 0; }

Mark the correct option

29. What is the output of this program? void main() { struct bitfields { int bits_1: 2; int bits_2: 9; int bits_3: 6; int bits_4: 1; }bit; printf("%d", sizeof(bit)); }

Mark the correct option

30. What is the output of this program? #include <stdio.h> int main(){ struct leader { char *lead; int born; }; struct leader l1 = {"AbdulKalam", 1931}; struct leader l2 = l1; printf("%s %d", l2.lead, l1.born); }

Mark the correct option

31. What is the output of this program? #include <stdio.h> struct employee { char *empname; int salary; }; int main() { struct employee e, e1; e.empname = "Sridhar"; e1 = e; printf("%s %s", e.empname, e1.empname); return 0; }

Mark the correct option

32. What is the output of this program? #include <stdio.h> struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); }

Mark the correct option

33. What is the output of this program? #include <stdio.h> void main() { struct number { int no; char name[20]; }; struct number s; s.no = 50; printf("%d", s.no); }

Mark the correct option

34. Number of bytes in memory taken by the below structure is #include <stdio.h> struct test { int k; char c; };

Mark the correct option

35. What is the output of this program? #include <stdio.h> struct student { char *c; }; void main() { struct student s[2]; printf("%d", sizeof(s)); }

Mark the correct option

36. Which of the following are incorrect syntax for pointer to structure? (Assuming struct temp{int b;}*my_struct;)

Mark the correct option

37. 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;)

Mark the correct option

38. For the following function call which option is not possible? func(&s.a); //where s is a variable of type struct and a is the member of the struct.

Mark the correct option

39. The correct syntax to access the member of the ith structure in the array of structures is? Assuming: struct temp { int b; }s[50];

Mark the correct option

40. The number of distinct nodes the following struct declaration can point to is struct node { struct node *left; struct node *centre; struct node *right; };

Mark the correct option