Leap, C, Exercism

/************************************************************
 *                                                          *
 *  Filename: leap.c                                        *
 *  Author:   krisyotam                                     *
 *  Date:     2024-12-18                                    *
 *                                                          *
 *  Description:                                            *
 *  This program determines whether a given year is a leap  *
 *  year based on the rules of the Gregorian calendar.      *
 *                                                          *
 *                                                          *
 *  Usage:                                                  *
 *  Call the leap_year() function with a year as input, and *
 *  it will return true if the year is a leap year, or      *
 *  false if it is not.                                     *
 *                                                          *
 *                                                          *
 *  Notes:                                                  *
 *  This function checks for leap years based on the rules  *
 *  of divisibility by 4, 100, and 400.                     *
 *                                                          *
 *  Test runs code in its own main file                     *
 *                                                          *
 ************************************************************/

#include "leap.h"
#include <stdbool.h>

bool leap_year(int year) {
    return (year % 4 == 0) && (year % 100 != || year % 400 == 0);
}

Bibliography

@misc{exercism-leap}
author Exercism
title Leap (C Track)
note Gregorian calendar leap year rules.
Last updated