C Program to calculate the day of year from the date

The following is a C program to calculate the day of year from the date:

Expected Output:

1st run:

2nd run:

How it works

Day of year is a number between 1 and 365 (or 366, if leap year). For example, 1st Jan is day 1, 5th Feb is day 36 and so on.

To calculate the day of year we simply add days in the given month to the days in the previous months.


Recommended Reading:

 

Leave a Comment

%d bloggers like this: