Haven't been coding since college, over 30 years ago

Joined
Jan 17, 2024
Messages
1
Reaction score
0
I coded in C language in 1991, and K&R's "C Programming Language" Second Edition was just out. I got a B in the class, an A on my final project, but I loved it. Then I got really sick and it took me completely out of college. I'm disabled today, without a job because of my sickness. But I want to relearn C and C++. So I drug out my text books, and bought a few new ones, and tried writing some programs. It's coming back to me.

This is a program that calculates your age in years, months and days, given user input their birthday. It takes care of all cases of leap year. Reads the system date and time. Pretty cool to be doing this again.
 

Attachments

  • main.pdf
    76.3 KB · Views: 10
Joined
Sep 21, 2022
Messages
122
Reaction score
15
If today is 29 April 2023 and a person was born 20 March 2023, then that person is 40 days old.

If I'm reading your program correctly, it outputs...

1 year; 1 month; 29 days
 
Joined
Sep 3, 2023
Messages
36
Reaction score
2
Seems to work fine. I had to add #include <stdlibs.h>

Code:
Age Program, by Doug Knecht 1/15/2024.


Enter birth month (xx):   03


Enter birth day (xx):   20


Enter birth year (xxxx):     2023


Today's date:   01-22-2024.


If you were born on 3-20-2023, you are:

0 years, 10 full months, and 33 combined total days (comprised of partial months) old.

Full months are (April, May, June, July, Aug, Sept, Oct, Nov, Dec) ... shouldn't that be 9?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top