Zeller's Algorithm Using C++

Adarsh Kumar Jha Mar 28, 2021

Zeller's congurence is an algorithm proposed by Christian Zeller which calculate the day of the weekfor a given year.

Zeller's congruence is an algorithm proposed by Christian Zeller which calculates the day of the week for a given year. The C++ program is used to find the day of the week for a given year, month, and date by a method known as the Zeller's Algorithm.
The algorithm uses the formula which is:
h = (d + (13 * (m + 1) / 5) + (y) + (y / 4) - (y / 100) + (y / 400)) mod 7
where,
1. 'h' is the day of the week (if h=1 then Sunday, if h=2 then Monday, and so on).
2. 'd' is the day of the month.
3. 'm' is a number corresponding to the month of the year.
4. 'y' is the year.

Project Files

Loading...
..
This directory is empty.

Comments (1)

Sysio 2026 years ago

<p>The code is erroneous. The expression</p> <p>x % 7</p> <p>cannot result in 7 so the last <strong>if</strong> branch should read</p> <p><strong>if(h == 0) ...</strong><br /><br />instead of</p> <p><strong>if(h == 7)...</strong></p> <p>otherwise Saturdays will never appear on output.</p>

Leave a Comment