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
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;
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)
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;