in qbasic how to print the time left for my birthday and my present age .. take the birth date as input..
Share
in qbasic how to print the time left for my birthday and my present age .. take the birth date as input..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
I now did it in all 3 possible ways...
- Using a loop: will return the correct results, except from leaplings
- Using average calculation: will mostly return correct results and sometimes return ages that are +1 or -1
- Using conditional checks: will probably (only tested 80000 times yet) return correct results, including leaplings
Explanation:
Private Function getPersonAge (Year As Integer, Month As Integer, Day As Integer, _
NowYear As Integer, NowMonth As Integer, NowDay As Integer) As Integer
If (NowMonth > Month) Or (NowMonth = Month And NowDay >= Day) Then getPersonAge = NowYear - Year Else getPersonAge = NowYear - Year - 1
End Function