leap year

closed account (o2TCpfjN)
The return type of isLeap is bool which has a value of either true or false. Complete the missing part of the following program:



#include <iostream>
using namespace std;
int main()
{
int year;
cin >> year;
if(isLeap(year)) {
cout << year << " is a leap year." << endl;
} else {
cout << year << " is a not leap year." << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}

















i do a sample buthas something wrong
i try three input 1111,1900&2000

1111-->is a leap year
1900-->is a leap year
2000-->is not aleap year

but it is reverse
what am i wrong???




#include <iostream>
using namespace std;

int isLeap(int);


int main()
{int year;

cin >> year;
if(isLeap(year)) {
cout << year << " is a leap year." << endl;
} else {
cout << year << " is a not leap year." << endl;
}





system("PAUSE");
return EXIT_SUCCESS;
}

int isLeap(int a){




if(a % 4 == 0 && a % 100 != 0 || a % 400 == 0){
bool isLeap = true;
}
else {
bool isLeap = false;

}

}


I think the problem is in the conditions you use in isLeap()
closed account (o2TCpfjN)
sorry idon't know how to correct this
can you help me correct the error??
isLeap is declared as an integer function, but does not have a return statement.

Given the useage, it woudl be better to declare isLeap as a bool, and where you have bool isLeap = true / false instead put return true / false
Topic archived. No new replies allowed.