Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: hwolfe71_leapyear.c #386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ Coding Experience: Discord Bot Developer (Java) + misc. wrappers. <br>
Programming Languages: Python 2/3, Java 8<br>
Email: [email protected]

Name: [Herb Wolfe](http://github.com/hwolfe71)<br />
Coding Experience: Java, C, Visual Foxpro<br />
Email: [email protected]<br />

Name: [Shubham Patil](https://github.com/shubhamdpatil)
Place: Pune, India
Coding Experience: C, python
Expand Down
14 changes: 14 additions & 0 deletions c/leapyear/hwolfe71_leapyear.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

// To run, compile with gcc, or use make,
// and run the executable with the year as the parameter.
// e.g. hwolfe71_leapyear 2003

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

int main(int argc, char *argv[]) {
printf("%s %s a leap year.\n", argv[1], (isLeapYear(atoi(argv[1])) ? "is" : "isn't"));
}