Hi
I have a bool function that should find whether a year was a leap year or not. But the function is not returning the correct years as a leap year.

``````#include <iostream>
#include <fstream>
#include <string>

using namespace std;

bool is_leapyear(int year);

int main () {

int a = 2000, b = 2004, c = 2005, d = 2007;

if (is_leapyear(a))
{
cout << a << " is a LEAP year" << endl;
}
else
cout << a << " is NOT a LEAP year" << endl;

if (is_leapyear(b))
{
cout << b << " is a LEAP year" << endl;
}
else
cout << b << " is NOT a LEAP year" << endl;

if (is_leapyear(c))
{
cout << c << " is a LEAP year" << endl;
}
else
cout << c << " is NOT a LEAP year" << endl;

if (is_leapyear(d))
{
cout << d << " is a LEAP year" << endl;
}
else
cout << d << " is NOT a LEAP year" << endl;

return 0;
}

bool is_leapyear(int year)
{
bool leap_yr = false;

if (((year % 4) == 0) && ((year % 100) != 0) || year % 16 == 0)
{
leap_yr = true;
}

else
leap_yr = false;

}``````

output for program is:

2000 is NOT a LEAP year
2004 is a LEAP year
2005 is a LEAP year
2007 is a LEAP year

is_leapyear(int) must return a value, it doesn't it only sets a bool value but doesn't return it. I added the return keyword before leap_yr = true; & leap_yr = false;, & my output were

2000 is a LEAP year
2004 is a LEAP year
2005 is NOT a LEAP year
2007 is NOT a LEAP year

Process returned 0 (0x0) execution time : 0.135 s
Press any key to continue.

Thanks! Its so obvious :P I should have known. Thanks for your help :)