hi i wannt ot make a programe in C inwhich user input current date and date of birth, output shows age in the number of years, months, days, etc.,
PLease help me!!!!!!!!!!!!!!
comsians 0 Newbie Poster
Recommended Answers
Jump to Posttime.h has a function named difftime() that returns the difference between two time_t variables in seconds.
Step 1: get birth date.convert it to struct tm the call mktime() which will return the time_t variable.
Step 2: call time() to get current data/time in time_t
Step 3. Call …
Jump to Postsimple --
const int seconds_per_minute = 60; const int seconds_per_hour = seconds_per_minute * 60; const int seconds_per_day = seconds_per_hour * 24; const int seconds_per_year = seconds_per_day * 365; int seconds = 123444445; int years = seconds % seconds_per_year;
Jump to PostI already told you.
Jump to PostCall time() to get the current data/time. This will give you the current time in seconds snce 1970. There is no function in time.h that returns the number of seconds since year 0 because it would be too big a number.
Now, once you have the year, month and …
Jump to PostThe code I posted earlier will get you the difference in seconds. All you have to do is make the calculations that I posted here.
I'm not going to do all the homewoprk for you. You have to learn how to use your head for something other than …
All 18 Replies
Martin B 4 Junior Poster in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sharathg.satya -10 Posting Whiz in Training
sharathg.satya -10 Posting Whiz in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Martin B 4 Junior Poster in Training
sharathg.satya -10 Posting Whiz in Training
sharathg.satya -10 Posting Whiz in Training
Martin B 4 Junior Poster in Training
sharathg.satya -10 Posting Whiz in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sharathg.satya -10 Posting Whiz in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sharathg.satya -10 Posting Whiz in Training
sharathg.satya -10 Posting Whiz in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Martin B 4 Junior Poster in Training
comsians 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.