/////

////
Last edited on
https://support.microsoft.com/en-us/kb/214019

You should check for a leap year separately from the last if statement (on line 82). The way you have it now it will only generate output if the year is a leap year. You could add a bit to your if statement that validates the day to consider when month == 2 and if it is a leap year. You could also add return statements to the if statements so that the program terminates when an invalid value is entered. For example (pseudo code):

1
2
3
4
5
6
7
8
if (1 <= day <= 31)
    if (month = 2)
        if (year is a leap year)
            if (day > 29)
                print "Invalid day"
        else
            if (day > 28)
                print "Invalid day"
//////
Last edited on
I tried it

Tried what? I made the modifications that I suggested and it appears to work for me. Can you post your modified code?
Topic archived. No new replies allowed.