//checks for leap year
bool checkLeapYr(int year)
{
 bool isLeap;
 if ((year%4=0) && (year %100!=0) || (year%400=0)) //error here. Non-Ivalue assignment
 {
  isLeap=true;            
  return isLeap;
 }
 else 
 {
  isLeap=false;
  return isLeap;
 }        
}//end function check leap year

i have the above function to check if a year is a leap year. The if statement is giving me a compilation error message "non-lvalue in assignment". Can anyone help me with it please?

Thank you.

Change = to ==

Keep it simpler, it's C++, not Pascal ;) :

//checks for leap year
bool checkLeapYr(int year)
{
    return year%4 == 0 && (year %100 != 0 || year%400 == 0);
}//end function check leap year//checks for leap year
commented: simpler is better +3

thanks for the tips. Still new to c++. Will be trying to improve my codes. :>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.