Name, Roll No., Date of Birth (Day, Month, Year)
Assign value to all the members of the structure.
PROGRAM
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
struct date{
int day;
int month;
int year;
};
struct student {
char name[50];
int rollno;
date dob;
};
void main()
{
clrscr();
student s1;
cout<<"\nEnter your name: ";
gets(s1.name);
cout<<"\nEnter your roll No: ";
cin>>s1.rollno;
cout<<"\nEnter birth date: ";
cin>>s1.dob.day;
cout<<"\nEnter birth month: ";
cin>>s1.dob.month;
cout<<"\nEnter birth year: ";
cin>>s1.dob.year;
cout<<"\nYour Name is "<<s1.name;
cout<<"\nYour Roll No is "<<s1.rollno;
cout<<"\nYour Date of Birth is "<<s1.dob.day<<"-"<<s1.dob.month<<"-"<<s1.dob.year;
getch();
}
No comments:
Post a Comment