PROGRAM TO SHOW NESTED STRUCTURES

/*PROGRAM TO SHOW NESTED STRUCTURES*/

#include<conio.h>

#include<iostream.h>

#include<stdio.h>

class nest_struct

{

struct dob

{

int day,year,month;

};

struct student

{

char name[10];

int roll_no;

dob d1;

}s1;

public:

void input();

void output();

};

void nest_struct::input()

{

cout<<“Enter the data of a student:\n”;

cout<<“Enter name: “;

gets(s1.name);

cout<<“Enter roll number: “;

cin>>s1.roll_no;

cout<<“Enter date of birth: “<<endl;

cout<<“Enter day: “;

cin>>s1.d1.day;

cout<<“Enter month: “;

cin>>dec>>s1.d1.month;

cout<<“Enter year: “;

cin>>s1.d1.year;

}

void nest_struct::output()

{

cout<<“Entered data of student is: \n”;

cout<<“Name: “<<s1.name<<endl;

cout<<“Roll number: “<<s1.roll_no<<endl;

cout<<“Date of Birth: “<<s1.d1.day<<” “<<s1.d1.month<<” “<<s1.d1.year<<endl;

};

void main()

{

nest_struct ns1;

clrscr();

ns1.input();

ns1.output();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *