Professional Documents
Culture Documents
#include<iostream.h>
class date
{
int dd,mm,yy;
public:
void getdate();
int operator-(date);
date operator+(int);
};
void date::getdate()
{
start: cout<<"\nenter a valid date [dd mm yy] :\n";
cin>>dd>>mm>>yy;
if((mm==2) && (dd>29))
{
cout<<"\nwrong input\n";
goto start;
}
if((mm>12) && (dd>31))
{
cout<<"\nwrong input\n";
goto start;
}
if((mm==4||mm==6||mm==9||mm==11) && (dd>30))
{
cout<<"\nwrong input\n";
goto start;
}
if((yy%4==0) && (mm==2) && (dd>28))
{
cout<<"\nwrong input\n";
goto start;
}
}
void main()
{
date dd1,dd2;
int num,res;
dd1.getdate();
dd2.getdate();
res=dd1-dd2;
cout<<"\nno of days : "<<res<<"\n";
cout<<"\nenter the no of days to be added to the first date: ";
cin>>num;
dd2=dd1+num;
}
no of days : 28
*/
plain text attachment [ scan and save to computer | save to yahoo! briefcase ]
void main()
{
dlist d;
int c,pos;
cout<<"creation of the list:\n";
d.create();
while(1)
{
cout<<"\n----------------menu------------------\n";
cout<<"\n1-insert\n2-delete\n3-display\n4-exit\n";
cout<<"\nenter your choice\n";
cin>>c;
switch(c)
{
case 1:cout<<"enter position where node is to be inserted:\n";
cin>>pos;
d.add(pos);
break;
case 2:cout<<"enter position of the node to be deleted:\n";
cin>>pos;
d.delet(pos);
break;
case 3:d.display();
break;
case 4:exit(0);
}
}
}
/* output
creation of the list:
enter data of the node:
2
any more nodes to be created 1-yes or 2-no
1
enter data of the node:
5
any more nodes to be created 1-yes or 2-no
1
enter data of the node:
6
any more nodes to be created 1-yes or 2-no
1
enter data of the node:
7
any more nodes to be created 1-yes or 2-no
1
enter data of the node:
9
any more nodes to be created 1-yes or 2-no
2
----------------menu------------------
1-insert
2-delete
3-display
4-exit
enter your choice
3
the nodes in the list are:
2 5 6 7 9
----------------menu------------------
1-insert
2-delete
3-display
4-exit
enter your choice
2
enter position of the node to be deleted:
3
the deleted node is:6
----------------menu------------------
1-insert
2-delete
3-display
4-exit
enter your choice
1
enter position where node is to be inserted:
3
enter the info of the node:
4
----------------menu------------------
1-insert
2-delete
3-display
4-exit
enter your choice
3
the nodes in the list are:
2 5 4 7 9
----------------menu------------------
1-insert
2-delete
3-display
4-exit
enter your choice
4