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 PostI'm sure I've said something like this before today, but I suggest you start by reading the date of birth into three integer variables, perhaps using scanf.
Let us know how you get on.
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 PostDo we really want to use functions in time.h?
Three integers for the current date, three integers for the DOB, then find the difference given an array of the lengths of months and the algorithm for checking if a year is a leap year (year divides by 4 and …
Jump to PostThere is no simple conversion between seconds and months or years.
You need to consider the number of days in each month of a timespan.
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.