ch 9/e4.c
//Function to calculate the value of N for a date

Function to calculate the value of N for a date
Function to calculate the value of N for a date
int calc_N_value ( struct date d )
	{
		int n = 0 ;
		if ( ( d.year == 1900 && d.month < 3 ) || d.year < 1900 )
			{
				n += 1 ;
				if ( ( d.year == 1800 && d.month < 3 ) || d.year < 1800 )
					n += 1 ;
			}
		if ( d.month <= 2 )
			{
				n += ( 1461 * ( d.year - 1 ) ) / 4 ;
				n += ( 153 * ( d.month + 13 ) ) / 5 ;
			}
		else
			{
				n += ( 1461 * d.year ) / 4 ;
				n += ( 153 * ( d.month + 1 ) ) / 5 ;
			}
		n += d.day ;
		return n ;		
	}
int calc_N_value ( struct date d ) { int n = 0 ; if ( ( d . year == 1900 && d . month < 3 ) || d . year < 1900 ) { n += 1 ; if ( ( d . year == 1800 && d . month < 3 ) || d . year < 1800 ) n += 1 ; } if ( d . month <= 2 ) { n += ( 1461 * ( d . year - 1 ) ) / 4 ; n += ( 153 * ( d . month + 13 ) ) / 5 ; } else { n += ( 1461 * d . year ) / 4 ; n += ( 153 * ( d . month + 1 ) ) / 5 ; } n += d . day ; return n ; }
Function to calculate the value of N for a date
Function to calculate the value of N for a date
//Adding 1 to n if date < Mar 1, 1900; and 2 if date < Mar 1, 1800
 // n = 1461 * f(year,month) / 4 + 153 * g(month) / 5 + day
