Computer scienceAlgorithms and Data StructuresIntro to algorithms and data structuresPseudocode and representation

Relations and conditions in pseudocode

Leap year

Report a typo

Create pseudocode that checks if the year is a leap one and stores the result in the isLeap variable. As you know, leap years are divisible by 4. However, there is an exception to this rule: centuries that are not divisible by 400 are not leap years (for example, 1900 wasn't a leap year).

Reorder lines using drag or arrows. Adjust indentation with left buttons
                if year mod 400 != 0 and year mod 100 == 0 then:
              
                else:
              
                isLeap = false
              
                isLeap = false
              
                isLeap = true
              
                elif year mod 4 == 0 then:
              
                year = 2000
              
___

Create a free account to access the full topic