Hi, I'm making a program that finds the number of days between two dates (so far you can only put in 1 date because my code is incomplete).

The code is incomplete right now but my problem is that the problem is that my code doesn't return a needed value. Say I choose the month as Feb (contains 28 days) and I put 10 as the day, it should return 18 but instead it returns -10.

I know the problem revolves somewhere around this code block

``````int DifferenceDays(int inputDay)
{
int Day;
Day = (Date1 - inputDay);
return Day;
}``````

but I'm not positive.

Here is the codes I have so far. Thanks!

``````#include <iostream>
using namespace std;
const int MONTH_LENGTH = 12;
int MinusOne(int);
int DifferenceDays(int);
int Date1;
int main()
{
int ListMonth [MONTH_LENGTH] = {30, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int Month;
int inputMonth;
int Day;
int inputDay;
cout << "This program calculates the days between two dates" << endl;
cout << "Enter the month (1-12)" << endl;
cin >> inputMonth;
Month = MinusOne(inputMonth);
cout << ListMonth[Month];
cout << "Enter the day of the month" << endl;
cin >> inputDay;
Day = DifferenceDays(inputDay);
cout << Day; //
return 0;
}

int MinusOne(int inputMonth)
{
int Month;
Month = (inputMonth - 1);
return Month;
}

int DifferenceDays(int inputDay)
{
int Day;
Day = (Date1 - inputDay);
return Day;
}``````

Nevermind I just figured it out after 1hour.

I'm really sorry if anyone had to waste their time reading this.