Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,701 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,496 people online right now. Registration is fast and FREE... Join Now!




day counter

 
Reply to this topicStart new topic

day counter, C++

Kcbroncofan
post 29 Nov, 2005 - 01:40 PM
Post #1


D.I.C Head

**
Joined: 28 Sep, 2005
Posts: 55


My Contributions


I need to write a program that prints the day number of the year. The user inputs the date in the form of month-day-year. The program needs to check for the leap year.
User is offlineProfile CardPM

Go to the top of the page

Nova Dragoon
post 29 Nov, 2005 - 01:41 PM
Post #2


The Innocent Shall Suffer, Big Time

Group Icon
Joined: 16 Aug, 2001
Posts: 6,125



Thanked 4 times

Dream Kudos: 515

Expert In: Python, Linux

My Contributions


have any code so far?


it would be fairly simple, first check if the inputted year can be a leap year, by basing your calcs off a known leap year like 2000

| 2000 - year | % 4 == 0 leap year

then hold days per month, in an array or something.

Then go through the array month by month, adding each element, stop on the month you are at, and add the day of the month to it. +1 if its a leap year and month is > feb
User is online!Profile CardPM

Go to the top of the page

area
post 29 Nov, 2005 - 02:59 PM
Post #3


New D.I.C Head

*
Joined: 22 Nov, 2005
Posts: 22


My Contributions


wow i gotta program that is similar to yours. its a pain in the butt but i have the joys of using functions blink.gif
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 29 Nov, 2005 - 03:32 PM
Post #4


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


There is another thread toucking on leap year calculations here.
User is online!Profile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 09:03AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month