===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long d1,m1,y1,d2,m2,y2,dR,mR,i,j,k;
long yR;
gotoxy(2,2);
cprintf("Enter Initial Date: \(dd\/mm\/yyyy\)");
gotoxy(23,2);
cscanf("%ld",&d1);
gotoxy(26,2);
cscanf("%ld",&m1);
gotoxy(29,2);
cscanf("%ld",&y1);
gotoxy(2,3);
cprintf("Enter Final Date: \(dd\/mm\/yyyy\)");
gotoxy(21,3);
cscanf("%ld",&d2);
gotoxy(24,3);
cscanf("%ld",&m2);
gotoxy(27,3);
cscanf("%ld",&y2);
for(i=y1,dR=0,mR=0,yR=0;i<=y2;i++)
{
dR++;
for(j=0;j<=12;j++)
{
if(i==y1 && j==0)
j=m1;
else if(j==0)
j=1;
if(j==1 || j==4 || j==6 || j==9 || j==11)
{
for(k=0;k<=30;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
else if(j==2)
{
if(i%4==0)
{
for(k=0;k<=29;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
else
{
for(k=0;k<=28;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
}
else
{
for(k=0;k<=31;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
mR++;
// cout<<dR<<" "<<j<<" "<<i<<"\n";
}
}
end:
yR=mR/12;
cprintf("\n\r\n\r In Between these Dates:-");
cprintf("\n\r %ld-Days %ld-Months %ld-Years [Including the End Date]",dR,mR,yR);
getch();
getch();
}
CODING
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long d1,m1,y1,d2,m2,y2,dR,mR,i,j,k;
long yR;
gotoxy(2,2);
cprintf("Enter Initial Date: \(dd\/mm\/yyyy\)");
gotoxy(23,2);
cscanf("%ld",&d1);
gotoxy(26,2);
cscanf("%ld",&m1);
gotoxy(29,2);
cscanf("%ld",&y1);
gotoxy(2,3);
cprintf("Enter Final Date: \(dd\/mm\/yyyy\)");
gotoxy(21,3);
cscanf("%ld",&d2);
gotoxy(24,3);
cscanf("%ld",&m2);
gotoxy(27,3);
cscanf("%ld",&y2);
for(i=y1,dR=0,mR=0,yR=0;i<=y2;i++)
{
dR++;
for(j=0;j<=12;j++)
{
if(i==y1 && j==0)
j=m1;
else if(j==0)
j=1;
if(j==1 || j==4 || j==6 || j==9 || j==11)
{
for(k=0;k<=30;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
else if(j==2)
{
if(i%4==0)
{
for(k=0;k<=29;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
else
{
for(k=0;k<=28;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
}
else
{
for(k=0;k<=31;k++)
{
if(i==y1 && j==m1 && k==0)
k=d1;
else if(k==0)
k=1;
if(j==m2 && i==y2 && k==d2)
goto end;
dR++;
}
}
mR++;
// cout<<dR<<" "<<j<<" "<<i<<"\n";
}
}
end:
yR=mR/12;
cprintf("\n\r\n\r In Between these Dates:-");
cprintf("\n\r %ld-Days %ld-Months %ld-Years [Including the End Date]",dR,mR,yR);
getch();
getch();
}
===========================================================================
No comments:
Post a Comment