Question

What do you understand by a nested structure? Explain with an example. Also, explain how would you access the members of a structure or a nested structure using pointers?

26 Feb 2024
Answer :
Word Count : 565

A nested structure in C is a structure definition that appears within another structure definition. It allows you to create a structure where one or more of its members are themselves structures.

Here's an example to illustrate a nested structure:


#include <stdio.h>

// Define a structure for storing date
struct Date {
    int day;
    int month;
    int year;
};

// Define a structure for storing student information, which includes a nested Date structure
struct Student {
    int rollNumber;
    char name[50];
    struct Date dob;  // Nested Date structure
};

int main() {
    // Declare a variable of type Student
    struct Student student1;

    // Assign values to the members of the nested structure
    student1.rollNumber = 101;
    strcpy(student1.name, "John Doe");
    student1.dob.day = 10;
    student1.dob.month = 5;
   

_________ _____ ______ ____ __________ ______ _________ _________ ______ _____.
____ ________ ____ ____ _________ ______.
____ _____ ______ __________ ___ __________ _____.
_____ _________ ________ __________ ___.
_____ ________ _______ ______ ________ ____ _______.
__________ _________ ________ ____ _____.
______ _____ __________ __________ __________ __________ _____ ___ ________ ________.
____ _____ ______ ___ ________ _______ ________ ________ _______ ____.
_________ __________ _________ ______ _________ ________.
___ ________ _________ ____ __________ ____ ____ ____ ____ _______ ____.
_____ ___ ____ __________ ___ __________ ________ ______ _________ _____ ___.
_____ __________ __________ __________ ______ ________ _____.
_____ ______ __________ ____ ______ _______ ______ ______ ____ _________.
_____ ______ _______ _________ ____ _______ ____ _______ ______ _________.
___ ____ ____ _____ ______ ________ _______ ___.
__________ _______ ___ __________ ______.
____ __________ ___ _________ __________ ____ _______ _________ ____ _____ __________.
____ ___ _____ ______ _____ ______ ________.
___ __________ __________ __________ __________.
___ ____ _____ ___ ________ ______ _______ _________ ________.
_______ _____ __________ ________ ___ _______ _______ ______ _______ ___ __________ ____.
_______ ______ ________ ______ ______ _______ _________.
________ ________ _________ ______ ____ _____ __________ ______ ______ _________ _____.
____ _____ ___ __________ ___ __________ _____ _____ _______ ___ ________.
__________ _________ ________ ___ ________ _________ _________ ___ _______ ______ ____ _________.
_________ ___ __________ _________ _________.
__________ _______ ______ ____ _____ ________.
_____ _________ _______ ________ _____ ________ __________ ____ ________ _______.
___ __________ ___ ______ ________ ____ ______ ____ _____ _______ _______ __________.
_____ ______ _______ ________ _____ ______ _____ _____ _____ _____ ___.
_________ ________ _____ _______ ___ ____.
_________ _____ ____ ________ ______.
_______ _______ ______ _______ _________.
__________ ______ ___ ________ __________ _____ _________ ___.
____ _______ _____ _____ ______ ______ ___ _________ _________.
________ _________ _________ ________ ________ ______ ____ _________ _________.
__________ _________ ________ _____ ________.
_____ _______ _____ _____ _______ ___ _________ ____ ____.
__________ __________ _____ ___ ___.
___ ______ _________ _________ __________ ___ ____ ________ __________.
__________ _____ _____ ______ ___ ___ ______ _______ ______.
_______ ___ ____ __________ _______ ______ ___ ___.
________ _________ _________ _____ _______ _________ _______.
______ __________ ___ _______ ______.
______ ___ ______ ________ _____ _______ _________ ____ __________.
______ _________ ________ ________ ______ ____ ____ __________ _____ _______ _______.
______ _________ ______ ____ __________ ___ _____ _________ __________ ________ ____.
________ _________ ________ __________ _____.
_________ ________ ____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MMT 1 2024 - What do you understand by a nested structure? Explain with an example. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→