C program to find the day of a date
Embed Embed this gist in your website. Share Copy sharable link for this gist. Learn more about clone URLs. Download ZIP. Find the day of a given date -- C program. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters. Copy link. I was unable to understand the logic for the weekday can any one help me please. I too face the same problem. Can you explain it clearly? Sign up for free to join this conversation on GitHub. Active Oldest Votes. Community Bot 1 1 1 silver badge. Thats it. Thirty days has September, April, June and November; all the rest have thirty-one, saving February alone, which has twenty-eight, rain or shine, and on leap years, twenty-nine.
A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by I don't think you can do it without some anchor — davka. Yes, of course.
The main thing is to be able to generate a sequential value for successive dates. Once you get that, you "adjust" the value to a known date by tweaking the part of the calculation. You can use the same formula with a different adjustment value and create the "davka day number" :- — pmg.
Why on earth are there all the backslashes at the ends of the lines in the code? None of them are necessary; this isn't a macro, and it isn't a string constant.
JonathanLeffler: the op wanted "just one line of C code" — pmg. DavidPetersonHarvey: you're right. There's no advantage in the 2nd version. Deleted it's in the Edits history — pmg. Show 3 more comments. Ben Ruijl Ben Ruijl 4, 3 3 gold badges 29 29 silver badges 39 39 bronze badges.
Friedrich Friedrich 5, 24 24 silver badges 43 43 bronze badges. Vivek Patel Vivek Patel 43 7 7 bronze badges. For Day of Week, years - Subtracted 1 from each instead of adding 6 in calc below. Subtract 1 from Month Table, so difference is 7.
James Venable James Venable 3 2 2 bronze badges. This one works: I took January as a reference. Pramod Pramod 4, 3 3 gold badges 41 41 silver badges 43 43 bronze badges. Antti Haapala k 21 21 gold badges silver badges bronze badges. Ashwin Kumar Ashwin Kumar 1.
Please explain your lines of code so other users can understand its functionality — Ignacio Ara. I wrote a small function to do this in C inspired by Conway's doomsday algorithm. Ptit Xav Ptit Xav 1, 2 2 gold badges 3 3 silver badges 11 11 bronze badges. Steve Summit Steve Summit 36k 6 6 gold badges 55 55 silver badges 80 80 bronze badges. Suraj Sunny Suraj Sunny 11 2 2 bronze badges.
Please make an edit to explain your code. At this time this is a code dump. When providing an answer please explain why your answer is right. SurajSunny: Please consider editing your answer to include a summary of the information provided in the youtube link. Stack Overflow expects your answer to be independent of any links.
See meta. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta.
0コメント