C# program to take birth year and tells age


Following program shows you how to take birth year and tells age.
In this program we get birth year from user and tells their age using currentYear - birthYear

using System;

class MainClass {
  public static void Main(string[] args) {
   Console.WriteLine("Please enter your date of birth:");
   int birthYear = Convert.ToInt32(Console.ReadLine());
   int age = 2018 - birthYear;
   Console.WriteLine("Your age is: " + age);
  }
}

Output:

Please enter your date of birth:
1985
Your age is: 33