Q:

C++ - program for Nested Structure (Structure with in Structure).

belongs to collection: C++ programs on various topics

0

C++ - program for Nested Structure (Structure with in Structure).

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C++ program - Demonstrate Example of Nested Structure

/*C++ - program for Nested Structure 
(Structure with in Structure).*/

#include <iostream>
using namespace std;

struct date_of_birth{
	int dd,mm,yy;
};

struct student{
	char name[30];
	int rollNumber;
	date_of_birth dob;
};

int main(){
	student s;
	cout<<"Enter name : ";
	cin.getline(s.name,25);
	cout<<"Enter roll number : ";
	cin>>s.rollNumber;
	cout<<"Enter date of birth (dd mm yy) : "  ;
	cin>>s.dob.dd>>s.dob.mm>>s.dob.yy;
	
	cout<<"Name:"<<s.name<<",Roll Number:"<<s.rollNumber<<endl;
	cout<<"Date of birth:"<<s.dob.dd<<"/"<<s.dob.mm<<"/"<<s.dob.yy<<endl;
	
	return 0;
}
    Enter name : Mike 
    Enter roll number : 101 
    Enter date of birth (dd mm yy) : 29 09 2000 
    Name:Mike,Roll Number:101 
    Date of birth:29/9/2000 

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ programs on various topics

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ - program for Array of Structure.... >>
<< C++ - Initialization of Array of Objects with Para...