skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Saturday, July 3, 2010
Difference between two dates
23.Difference b/w two dates
#include<iostream.h> #include<conio.h> class date { int dd,mm,yy; public: void getdata() { cout<<"\nEnter date(dd mm yyyy) "; cin>>dd>>mm>>yy; } int diff(date t) { int i=1,a,b,c,al,bl,cl,dif=0,f=0; if(yy==t.yy) { if(mm==t.mm) { if(dd<t.dd){i=0;} else if(dd==t.dd){i=2;} else{i=1;} } else if(mm<t.mm){i=0;} else{i=1;} } else if(yy<t.yy){i=0;} else{i=1;} if(i==0) { a=dd; b=mm; c=yy; al=t.dd; bl=t.mm; cl=t.yy; } else if(i==1) { a=t.dd; b=t.mm; c=t.yy; al=dd; bl=mm; cl=yy; } if(i==2) return 0; else { while(a!=al||b!=bl||c!=cl) { a++; if(b==2) { if(c%4!=0||(c%100==0&&c%400!=0)) f=28; else f=29; } else if(b==4||b==6||b==9||b==11) f=30; else f=31; if(a>f) { b++; a=1; } if(b>12) { c++; b=1; } dif++; } return(dif); } } }; void main() { clrscr(); date d1,d2; d1.getdata(); d2.getdata(); int dif=d2.diff(d1); cout<<"\nDifference= "<<dif; getch(); }
1 comment:
Unknown
August 17, 2018 at 7:37 AM
What is this?
It's only header files
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
►
October
(4)
▼
July
(1)
Difference between two dates
►
May
(22)
About Me
Arun Ramesh
View my complete profile
What is this?
ReplyDeleteIt's only header files