Nested Structure

Medium Structures & Unions
Solve in Playground →

Problem Statement

Write a C program using a nested structure to store student details including date of birth (day, month, year) and print them.

Input Format

Name, followed by day, month, and year of birth.

Output Format

Print 'Name: X, DOB: DD/MM/YYYY'.

Constraints

1 <= Day <= 31, 1 <= Month <= 12, 1950 <= Year <= 2010

Sample Input

John 15 8 2002

Sample Output

Name: John, DOB: 15/08/2002

Explanation

Nests a Date structure inside a Student structure.

Starter Code

#include <stdio.h>

struct Date {
    int day;
    int month;
    int year;
};

struct Student {
    char name[51];
    struct Date dob;
};

int main() {
    struct Student s;
    if (scanf("%50s %d %d %d", s.name, &s.dob.day, &s.dob.month, &s.dob.year) == 4) {
        // Write your code here
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used