'How would you word this function differently?

My calculations are incorrect in the sense that my program thinks, for example, that 2022 is a leap year and 2024 is not. How do I fix this, please?? I've tried changing the bool statement but nothing seems to work.

#include <iostream>

int leapYear(int year)
{
    return (((year % 400) == 0) || ((year % 4 == 0)&& !(year % 100 == 0)));
}
// extracted
}
c++


Solution 1:[1]

I'd just answer the title


with c++20 you can use std::chrono to do it

std::chrono::year{y}.is_leap()

godbolt link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1