#170 – The else Portion of an if Statement

An if statement can optionally include an else keyword and block of statements, which will execute if the boolean expression for the if statement evaluates to false.

            if (age >= 50)
            {
                Console.WriteLine("Hey, you should consider joining AARP!");
                DisplayDetailsOfAARPMembership();
            }
            else
            {
                Console.WriteLine("You're still a young pup");
                DisplayInfoAboutVideoGames();
            }
Advertisements