All articles
c

A program to explain NESTED STRUCTURE

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 091

  • Write a program to explain NESTED STRUCTURE

Program

#include <stdio.h>
 
struct A
{
    int x;
};
 
struct B
{
    int y;
    struct A a;
};
 
int main()
{
    struct B b;
    b.a.x = 10;
    b.y = 20;
 
    printf("x = %d, y = %d", b.a.x, b.y);
    printf("\n");
 
    return 0;
}

Result

x = 10, y = 20

Comments