I need help with Day Number program, I have already got the Leap Year subprogram to work, but I need help with the day number program as far as how to set it up and incorporate the leap year program. Here is the scenario and below that the leap year subprogram. Write a function dayNumber that returns the day number (1 to 366) in a year for a date that is provided as input data. Your function should accept the month (1 through 12), day, and year as integers. As an example. For example, January 1, 1994 is day one. December 31 2004 is day 366 because its a leap year. A leap year is divisible 4, except that any year is divisible by 100 is a leap year only if it is divisible by 400. Write a second function that returns true if its argument, a year, is a leap year. Also I cannot use loops or arrays of any sort. Just calling on these subprograms. Any help would be much appreciated! Code: #include <iostream> using namespace std; bool checkLeapYr(int year) { if ((year%4==0) && (year %100!= 0) || (year%400 == 0)) { return true; } else { return false; } }
Well, how would you do it on paper? What day number is 14th March 2003? 14th March 2004? If you can't use arrays then you'll have to use fixed constants in the program, so you might want to consider a daysInMonth() function that takes the month and year and returns the number of days in that month (obviously it only needs the year for February).