Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Structure & Union | Question 10

  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021

Predict the output of following C program

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




#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;
}

(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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!