I have been assigned to write a program to print the calendar of a given year. Its almost complete, but, I haven't yet found a proper algorithm to find the first day of the year which is required by the function to print the calendar year.

>I was looking for a more simple solution in terms of formula or such.
An ad hoc solution isn't going to be simpler. It's also going to be less powerful, less flexible, less accurate, and potentially buggy. But you go ahead and use your "simpler" solution and I won't bother offering a better one next time. :icon_rolleyes:

>Thanks anyway.
"Thanks anyway" is a polite sounding way of saying "You were no help, I solved my own problem, so long losers". I'd recommend avoiding that particular phrase in favor of "Thanks for your help".

>I was looking for a more simple solution in terms of formula or such.
An ad hoc solution isn't going to be simpler. It's also going to be less powerful, less flexible, less accurate, and potentially buggy. But you go ahead and use your "simpler" solution and I won't bother offering a better one next time. :icon_rolleyes:

>Thanks anyway.
"Thanks anyway" is a polite sounding way of saying "You were no help, I solved my own problem, so long losers". I'd recommend avoiding that particular phrase in favor of "Thanks for your help".

Alright, let me put this in this way - I am still starting out with C++, so, I found your solution a bit complex and more importantly I was looking for a mathematical formula. A mathematical formula when proven right can in no way be called "ad hoc". "Less powerful" - maybe; "Less flexible" - agreed; "Less accurate" - no way; "Potentially buggy" - read my last line.

I might sound arrogant here but, I really had to answer this, this way.
And thanks for the help.

>A mathematical formula when proven right can in no way be called "ad hoc".
Sure it can. It's like rewriting bubble sort each time you need it. Of course, that formula also hasn't been proven right as far as I can tell. There's no formal proof that I could find in your link, it just looks like some random dude got bored and spent an hour coming up with it.

>"Less powerful" - maybe
You mean definitely. Your mathematical formula does one thing, and only one thing. To do something else, you need a completely different formula. That's clearly less powerful.

>"Less accurate" - no way
Really. It seems you haven't done much date programming, because it's a lot more complicated than you seem to think. The only way you can turn a general date question into a clean formula is to make assumptions and significantly limit the date range and/or accuracy of the result. If you restrict yourself to those limitations the formula will be accurate, but with the limitations in place, you can't say that your formula answers the general question.

>"Potentially buggy" - read my last line.
You're right. Change that to "definitely buggy", because anyone with your attitude about solutions clearly doesn't have correctness in mind.

How can I make this to continue until the user presses N? I've tried using while(1), while( option == 'y' || option == 'Y') but it kept giving an error ...