Pick the best statement for the below program:
(A) Compile error because struct type (containing two fields of dissimilar type i.e. an int and a char) has been mentioned along with definition of myVar of that struct type.
(B) Compile error because of incorrect syntax of initialization of myVar. Basically, member of operator (i.e. dot .) has been used without myVar.
(C) Compile error for not only B but for incorrect order of fields in myVar i.e. field c has been initialized first and then field i has been initialized.
(D) No compile error and it’ll print 100 A.
Explanation: As per C language, initialization of a variable of complete data type can be done at the time of definition itself. Also, struct fields/members can be initialized out of order using field name and using dot operator without myVar is ok as per C. Correct answer is D.
Quiz of this Question
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- C Quiz - 101 | Question 3
- C Quiz - 101 | Question 4
- C Quiz - 112 | Question 2
- C Quiz - 111 | Question 5
- C Quiz - 112 | Question 1
- C Quiz - 109 | Question 1
- C Quiz - 101 | Question 2
- C Quiz - 101 | Question 1
- C Quiz - 112 | Question 5
- C Quiz - 112 | Question 3
- C Quiz - 104 | Question 3
- C Quiz - 104 | Question 4
- C | C Quiz - 113 | Question 1
- C Quiz - 111 | Question 4
- C Quiz - 101 | Question 5