| Programming PHP | PERL | ASP| ColdFusion| C++ Chat with other forum members about programming. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
Program is to find no. of days between 2 dates.Logic is to add 1 day to 1 date till it reaches other.#include#includevoid main(){int a,b,c,d,e,f,flag=0;printf("Enter first date");scanf("%d%d%d",&a,&b,&c);printf("Enter second date");scanf("%d%d%d",&d,&e,&f);while(c!=f||b!=e|| a!=d) //If I comment c!=f this program works otherwise it goes infinite!{a++;if((b==4)||(b==6)||(b==9)||(b==11))f =30;else if(b==2){if(d%4==0)f=29;elsef=28;}elsef=31;if(a>f) {b++;a=1;}if(b==13){c++;b=1;}flag++;}printf("%d",f lag);getch();}
|
|
|||
i did this program its to find persons age& hw many days he lived its very simplefirst u substracted the old year from recent yearthan answer*365other line subtract large month to smaller 1 than answer*30than just add the days ok that was mine i wont do ur prob i might get answer 2moro when i go to my class
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT. The time now is 12:09 AM.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Ad Management by RedTyger





Linear Mode
