-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.cpp
More file actions
52 lines (52 loc) · 834 Bytes
/
date.cpp
File metadata and controls
52 lines (52 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "iostream"
using namespace std;
class date
{
int day,month,year;
public:
date(int a,int b,int c)
{
day=a;
month=b;
year=c;
}
void setday(int a)
{
day=a;
}
void setmonth(int a)
{
month=a;
}
void setyear(int a)
{
year=a;
}
void print_sdate()
{
if (day<10)
cout<<"0"<<day<<"-";
else
cout<<day<<"-";
if (month<10)
cout<<"0"<<month<<"-";
else
cout<<month<<"-";
cout<<year<<endl;
}
void print_ldate()
{
char months[12][20]={"January","Februaury","March","April","May","June","July","August","September","October","November","December"};
cout<<"\n"<<months[month-1]<<" "<<day<<","<<year<<endl;
}
};
int main()
{
int a,b,c;
cout<<"Enter day,month,year\n";
cin>>a>>b>>c;
date d1(a,b,c);
d1.print_sdate();
d1.print_ldate();
return 0;
}