FIXING ERROR IN MAIN FUNCTION...Date validator program..

hi..im trying to make Date validator.. can you help me to fix error...i cant run this program..because of some errors... says undefined result,false,bool, true in main function...and can you please help me with my call function?if it is ok?..thanks




************************Includes**************************************/

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

/************************Function call*********************************/

int isLeapYear(int year); //function
int dateIsValid (int day, int month, int year); //function


/***********************Main******************************************/

int main()
{
int value1, value2, value3;
char again;

do
{
cout << "Enter the day, month, and year. \n";
cin >> value1 >> value2 >> value3;
dateIsValid(value1, value2, value3); //call function
cout << value1<<" "<< value2 <<" "<< value3<<endl;
cout << " Do you want to enter another date? (Y/N)";
cin >>again;

}while (again =='Y' || again =='y');

return 0;
}

/*************************FUNCTION*********************************/

int dateIsValid(int day, int month, int year)

{
bool valid;
int monthLength[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

if ( isLeapYear(year) )
monthLength[2] = 29; // 29 days in February in a leap year

if ( month < 1 || month > 12 )
valid = false;
else if ( day < 1 || day > monthLength[month] )
valid = false;

return ( valid );

}

/****************************FUNCTION*******************************************/

int isLeapYear(int year)
{
bool result;

if ( (year%4) != 0 ) // or: if ( year%4 )
result = false; // means: if year is not divisible by 4
else if ( (year%400) == 0 ) // or: if ( !(year%400) )
result = true; // means: if year is divisible by 400
else if ( (year%100) == 0 ) // or: if ( !(year%100) )
result = false; // means: if year is divisible by 100
else // (but not by 400, since that case
result = true; // considered already)

return ( result );

}


No error in code, it is being compiled and works fine. Only a little bit senseless. Maybe this one will be better:

int main()
{
int value1, value2, value3;
char again;

do
{
cout << "Enter the day, month, and year. \n";
cin >> value1 >> value2 >> value3;
if (dateIsValid(value1, value2, value3)) {
cout<<"Date is valid"<<endl;
} else {
cout<<"Date is invalid"<<endl;
} //call function
cout << value1<<" "<< value2 <<" "<< value3<<endl;
cout << " Do you want to enter another date? (Y/N)";
cin >>again;

} while (again =='Y' || again =='y');

return 0;
}

Can you provide the list of errors ???
Topic archived. No new replies allowed.