Sunday, March 17, 2013

Nested Structures

#include<iostream>
using namespace std;
struct date{
              int year;
              int month;
              int day;
           };
struct student{
                 char name[30];
                 date dob;
              };
int main()
{
    student s1;
    cout<<"Enter Name : ";
    cin.getline(s1.name,28);
    cout<<"Enter DOB : ";
    cout<<"\n\nYear: ";
    cin>>s1.dob.year;
    cout<<"Month: ";
    cin>>s1.dob.month;
    cout<<"Day: ";
    cin>>s1.dob.day;
    cout<<"\n\n";
    cout<<"Name: "<<s1.name;
    cout<<"\nDOB: "<<s1.dob.day<<" - "<<s1.dob.month<<" - "<<s1.dob.year;
    return 0;
}

0 comments:

Post a Comment