Hello,
I need to write a program that calculates how many days from year January 1, 0000 to any specified date including leap years. When I run the program that I have, I am off by a few days for any given date. Can someone please check out my code and see what I'm doing wrong. I am new to C++ so please cut me some slack if there are simple errors that I have missed. Just a side note...in "library.h" there are commands that are different that in just C++ (i.e. print command).
#include "library.h"
int const day_of_forever(int const year, int const month, int const day)
{
int count[]={0,31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
if ((year % 4==0) && (year % 100 != 0) && (year % 400 == 0 )&& (month>=2)) ((count[month]+day)+1);
return (count[month-1]+day)+(((year)*365)+1) +((year)/4)-(year/100)+(year/400);
}
void main()
{
int const year=1776;
int const day=7;
int const month=4;
int const something=day_of_forever(year,month,day);
print (something);
}