Tech Study

Write a C program to demonstrate example of Nested Structure

Introduction

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.

#include <stdio.h>
 
struct student{
    char name[30];
    int rollNo;
 
    struct dateOfBirth{
        int dd;
        int mm;
        int yy;
    }DOB;
};
 
int main()
{
    struct student std;
 
    printf("Enter name: "); 
    gets(std.name);
    printf("Enter roll number: ");	scanf("%d",&std.rollNo);
    printf("Enter Date of Birth [DD MM YYYY] format: ");
    scanf("%d%d%d",&std.DOB.dd,&std.DOB.mm,&std.DOB.yy);
    printf("\nName : %s \nRollNo : %d \nDate of birth : %02d - %02d - %02d\n",std.name,std.rollNo,std.DOB.dd,std.DOB.mm,std.DOB.yy);
 
    return 0;
}

Result

Write a C program to demonstrate example of Nested Structure

Write a C program to demonstrate example of Nested Structure

TaggedWrite a C program to demonstrate example of Nested Structure

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more