C | Structure & Union | Question 10
Predict the output of following C program
#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
filter_none
(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
Recommended Posts:
- C | Structure & Union | Question 7
- C | Structure & Union | Question 6
- C | Structure & Union | Question 8
- C | Structure & Union | Question 9
- C | Structure & Union | Question 1
- C | Structure & Union | Question 2
- C | Structure & Union | Question 5
- C | Structure & Union | Question 10
- C | Structure & Union | Question 4
- Difference between Structure and Union in C
- Anonymous Union and Structure in C
- Output of C++ programs | Set 41 (Structure and Union)
- Output of C programs | Set 44 (Structure & Union)
- Union in C
- C | Loops & Control Structure | Question 6