function probelm

Well, I asked for help on this last week, The provision was great, worked well, now I need this code to be in a call to function format. I have worked on this a while and can not get it to properly function. Any help would be great.

/
* Program Description: This program will accept the input of a date and output its numbered day of the year
* Program Design: The daynum function will return the day number in a year for a date that is
provided as input. It will calculate the number days from 1 to 365
unless it is a leap year else it will calculate from 1 to 366.
*/

#include <iostream>
#include <iomanip>
using namespace std;

//funtion prototype
void dayNumber(month,day, year);
void leap(year);

int main()
{
int (month, day, year);
char c;
bool (leap) = false;

{
cout << "Enter a date in the form MM-DD-YYYY: ";
cin >> month >> c >> day >> c >> year ;

system ("cls");

daynumber(month, day, year);

leap(year);




// Then add the day number to that sum
int dayNum = sum + day;

cout << " The day number for " << month << "/" << day << "/" << year << " is " << dayNum << endl;

system ("pause");
return 0;
/* end main*/

}
void leap(year)
{
int numberOfDaysInMonth = 0;
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
numberOfDaysInMonth = 31;
break;

case 4:
case 6:
case 9:
case 11:
numberOfDaysInMonth = 30;
break;

case 2:
if (((year % 4 == 0) && (year % 100 != 0))
|| (year % 400 == 0))
numberOfDaysInMonth = 29;
else
numberOfDaysInMonth = 28;
}

if (day < 1 || day > numberOfDaysInMonth)
leap = false;
else
leap = true;
} //end leap
// compute the day number
// Add up the number of days in all earlier months
// of this year

void dayNumber(month,day, year)
int sum = 0;
for (int m = 1; m < month; ++m)
{
int monthLength = 0;
switch (m)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
monthLength = 31;
break;

case 4:
case 6:
case 9:
case 11:
monthLength = 30;
break;

case 2:
if (((year % 4 == 0) && (year % 100 != 0))
|| (year % 400 == 0))
monthLength = 29;
else
monthLength = 28;
}

sum += monthLength;
}//end dayNumber
Topic archived. No new replies allowed.