Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 10-09-2010, 10:48 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2010
Posts: 14
Default [C] Program to find period of days


please help with this C program

write a program that finds number of days between a period entered by user.Check invalidity also.


I tried to write the program but it became too long considering fact that months had to be converted into days depending whether they had 30 or 31 days and years also converted into days depending whether i was leap yr or not.....Am I going the right way or wandering off ????

Help in both the cases
technique_007 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 11-09-2010, 06:36 AM   #2 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default Re: help with a program

you should make use of time.h functions available like difftime and time_t type - See The GNU C Library - Date and Time for reference in time functions

Arun
sakumar79 is offline   Reply With Quote
Old 11-09-2010, 07:55 PM   #3 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2010
Posts: 14
Default Re: help with a program

@sakumar
thx for reply, but we have been taught only upto loops(to be specific 'for' loop) till now.
So I dont think time.h function is required to be used...

can u suggest a simpler way..plzz
technique_007 is offline   Reply With Quote
Old 12-09-2010, 12:31 AM   #4 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: help with a program

you are doing the right way, um in the way the question has asked you to do
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 12-09-2010, 11:54 AM   #5 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2010
Posts: 14
Default Re: help with a program

@liverpool fan

kk.....but i am stuck at this point only....

can u suggest as how to write all this stuff ??
technique_007 is offline   Reply With Quote
Old 12-09-2010, 12:15 PM   #6 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default Re: help with a program

Create functions for each task - checking validity of a date, leap year check, etc and simplify your main function by calling each separately...

One possibility is you can create a function that returns the number of days a date is after 1/1/0001 AD and then take the difference of the result for the two dates...

Arun
sakumar79 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Post your C/C++ Programs Here Gigacore Programming 746 27-11-2011 05:20 PM
JAVA or DOT Net... NIIT 99days program ~~Big Boss~~ Career Planning and Progression 8 27-11-2010 08:02 PM
An Unofficial guide to spywares and online safety .. it_waaznt_me Tutorials 33 14-07-2009 11:42 AM
List of Programs having issues with Windows XP SP2 leech Software Q&A 15 31-08-2004 10:48 AM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2