C | Structure & Union | Question 10

Predict the output of following C program

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<stdio.h>
struct Point
{
  int x, y, z;
};
  
int main()
{
  struct Point p1 = {.y = 0, .z = 1, .x = 2};
  printf("%d %d %d", p1.x, p1.y, p1.z);
  return 0;
}

chevron_right


(A) Compiler Error
(B) 2 0 1
(C) 0 1 2
(D) 2 1 0


Answer: (B)

Explanation: Refer designated Initialization discussed here.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up