Create
a structure of type date that
contains three members: the month, the day of the month, and the year, all of
type int. (Or use day-month-year order if you prefer.) Have the user enter a
date in the format 12/31/2001, store it in a variable of type struct date, then
retrieve the values from the variable and print them out in the same format.
SOLUTION:
#include<iostream.h>
#include<conio.h>
/////////////////////////////////////////////////////////////
Define Structures
////////////////////////////////////////////////////////////
struct date
{
int month,day,year;
};
///////////////////////////////////////////////////// Define Structure Variables
/////////////////////////////////////////////////////
date date1;
void main()
{
clrscr();
/////////////////////////////////////////////////////////////////
Take Input
////////////////////////////////////////////////////////////////////
cout<<"Enter Month ";
cin>>date1.month;
cout<<"Enter Day ";
cin>>date1.day;
cout<<"Enter year ";
cin>>date1.year;
//////////////////////////////////////////////////////////////////////
Output
/////////////////////////////////////////////////////////////////////
cout<<"\nDate is
"<<date1.month<<"/"<<date1.day<<"/"<<date1.year;
getch();
}
OUTPUT:
![](file:///C:\Users\MUHAMM~1\AppData\Local\Temp\msohtmlclip1\01\clip_image002.jpg)
0 comments: