can someone tell me what those %7 and %4 means?

I've tried solving it using calculator but my answers are really different from this code?

#include<stdio.h>

main ()
{
 int year=1996, daycode;

 daycode=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7;
 printf("%d",daycode);


}

and also this one

#include<stdio.h>

main ()
{
 int year=1996, leapyear;

 leapyear=(!(year%4)&&(year%100))||!(year%4);
 printf("%d",leapyear);


}