Hey there, I have been working on creating a program which calculates the number of days inbetween two dates. I have got most of the program going, but it produces some unusal results and i'm not quite sure why. Could anyone point me in the right direction?

Code:
#include <stdio.h>
#include <stdlib.h>



long days(int sm, int sd, int sy, int em, int ed, int ey);
long factor(int mm, int dd, int yy);

int main(int argc, char *argv[])
{
int sm, sd, sy; // starting date
int em, ed ,ey; // ending date
long old;

printf("\n Calculate days between two dates .....");
printf("\n\n Enter first date in mm/dd/yyyy format: ");
scanf("%d/%d/%d",&sm,&sd,&sy);
printf("\n Enter second date in mm/dd/yyyy format: ");
scanf("%d/%d/%d",&em,&ed,&ey);
old = days(sm,sd,sy,em,ed,ey);

printf("\n There are %ld days between %d/%d/%d and %d/%d/%d\n",
old,sm,sd,sy,em,ed,ey);

system("PAUSE"); 
return 0;
}

long days(int sm, int sd, int sy, int em, int ed, int ey)
{
long fac1, fac2, elap;

fac1 = factor(sm, sd, sy);
fac2 = factor(em, ed, ey);
elap = fac2 - fac1;
return (elap);
}

long factor(int mm, int dd, int yy)
{
long xx;

xx = 365 * yy + dd + 31 * (mm - 1);
if (mm < 3)
xx = xx + ((yy -1)/4) - (.75 * ((yy - 1)/100)+1);
else
xx = xx - (.4 * mm + 2.3) + (yy / 4) - (((.75 * (yy / 100) + 1)));
return (xx);
}
Many thanks