LearnFrenzy
Sign in Take a free test

Declarations and Initializations · Predict the Output · Question 3

A designated member followed by a positional value Answer, explanation & discussion

  • Output
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What is the output of the following C program on a 64-bit system?

main.c
#include <stdio.h>

struct date {
    int d, m, y;
};

int main(void) {
    struct date dt = {.m = 8, 2026};
    printf("%d %d %d\n", dt.d, dt.m, dt.y);
    return 0;
}
  • A 0 8 2026 Correct
  • B 2026 8 0
  • C 8 2026 0
  • D Compilation error
Correct Answer: Option A

After a designator, the next plain value initialises the member that follows it: m is 8, then y is 2026. d is not mentioned, so it is 0.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links