HELP MonthDayYear

Whenever I run the program I get no errors yet it doesn't return a value for total it just exits the program.


#include <iostream>
using namespace std;
int totaldays();
int days();
int month, day, year;
bool leap();

int main()
{
char dash;

cout << "Enter the date in mm-dd-yyyy format to find out what day this is in the year." << endl;
cin >> month >> dash >> day >> dash >> year;

}
bool leap(int year)
{
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
return true;
else
return false;
}

int days(int month, int year)
{
switch (month)
{
case 9:
case 4:
case 6:
case 11:
return 30;
break;
case 2:
if (leap(year))
return 29;
else
return 28;
default: return 31;
}
}

int totaldays(int day,int month, int year)
{
int total = 0;
for (int i = 0; i < month; i++)
total = total + days(month, year);

total = total + day;
return total;
}
Hi,

First up please always use code tags - select your code and press the <> button on the format menu.

Your main function is doing exactly as advertised: once it has the user input, the program ends. None of your functions are called.

Try to avoid having global variables.

Google to see why you shouldn't have line 2.

Hope this helps :+)
Topic archived. No new replies allowed.