"Tom" writes:
> Hello, please help me, I need two write a C++ program that can
> calculate the number of days between two dates.

Presuming this is a student exercise.....

Top down design is usually preferred but in this case I think it would be OK
to do bottom up. IOW, it isn't really design, it's a Topsy like growth from
the bottom up. You can surely do that for two dates in the same month,
right? Do that. Then consider adjacent months. where neither one of them
is February. Then allow for intervening months in the same year. Then
different years where neither year is a leap year. Then handle leap years
properly. Look in a good dictionary, the leap year rule might have more
rules than you know about.

After completing something like this sequence you will have learned a lot
and you can throw all that code away and write a nice pretty program that
does what you have been asked to do.

On 2006-03-16, osmium <> wrote:
> "Tom" writes:
>> Hello, please help me, I need two write a C++ program that can
>> calculate the number of days between two dates.
>
> Presuming this is a student exercise.....
> <snip>
> If this is not a student exercise, look up Julian day number.

Or difftime.

--
Neil Cerutti
Low Self-Esteem Support Group will meet Thursday at 7 to 8:30
p.m. Please use the back door. --Church Bulletin Blooper

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!