5+ C Sharp Age Calculator Programs

This post contains a total of 5+ C Sharp Age Calculator Program Examples with Source Code. All these Age Calculator Programs are made using C Sharp.

You can use the source code of these examples with credits to the original owner.

Related Posts

C Sharp Age Calculator Programs

1. Age Calculator in C#

Made by Beverly Ag. Source

2000
You are  22 years old.
You are still YOUUNNNNG!!!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 2022;
            var y = Convert.ToInt32(Console.ReadLine());
            int age = x - y;
            
            
            if (age >= 60){
                Console.WriteLine("You are  {0} years old." , age );
 Console.WriteLine ("You are OOOOLLLLLD!!! \nEnjoy your Life to the fullest!!!!");           
            }
            if (age < 60){
                Console.WriteLine ("You are  {0} years old.", age );
 Console.WriteLine ("You are still YOUUNNNNG!!!!\nEnjoy your Life to the fullest!!!!!");               
            }
        
       }
    }
}

2. C# program for age calculator

Made by Shahriar Hossain. Source

Present Age
Years: 21 Months: 11 Days: 22
using System; 

class GFG { 

	static void findAge(int current_date, 
					int current_month, 
						int current_year, 
						int birth_date, 
						int birth_month, 
						int birth_year) 
	{ 
		int []month = { 31, 28, 31, 30, 31, 30, 
					31, 31, 30, 31, 30, 31 }; 

		// if birth date is greater then 
		// current birth_month, then donot 
		// count this month and add 30 to the 
		// date so as to subtract the date and 
		// get the remaining days 
		if (birth_date > current_date) 
		{ 
			current_month = current_month - 1; 
			
			current_date = current_date 
					+ month[birth_month - 1]; 
		} 

		// if birth month exceeds current month, 
		// then do not count this year and add 
		// 12 to the month so that we can 
		// subtract and find out the difference 
		if (birth_month > current_month) 
		{ 
			current_year = current_year - 1; 
			current_month = current_month + 12; 
		} 

		// calculate date, month, year 
		int calculated_date = current_date 
								- birth_date; 
								
		int calculated_month = current_month 
								- birth_month; 
								
		int calculated_year = current_year 
								- birth_year; 

		// print the present age 
		Console.WriteLine("Present Age"); 
		Console.WriteLine("Years: "
						+ calculated_year + 
				" Months: " + calculated_month 
			+ " Days: " + calculated_date); 
	} 
	
	// driver code to check the above function 
	public static void Main() 
	{ 
		
		// present date 
		int current_date = 7; 
		int current_month = 12; 
		int current_year = 2022; 

		// birth dd// mm// yyyy 
		int birth_date = 16; 
		int birth_month = 12; 
		int birth_year = 2000; 

		// function call to print age 
		findAge(current_date, current_month, 
				current_year, birth_date, 
				birth_month, birth_year); 
	} 
} 

3. Age Calculator Program by SebastiΓ‘n A

Made by SebastiΓ‘n A. Source

Enter your birthday year
2000
You have this year 20 years old
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
        
        int age = 0;
        int year = 0;
        string value = "";
        
            Console.WriteLine("Enter your birthday year");
            value = Console.ReadLine();
            
            year = Convert.ToInt32(value);
            
            age = 2022 - year;
            
            Console.WriteLine("You have this year {0} years old", age);
        }
    }
}

4. Age Calculator c#

Made by Tebogo Nomnqa. Source

2002
You are 20 years old
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//simply enter your birth year nothing else nothing more
namespace AgeCalculator
{
	class Program
	{
		static void Main(string[] args)
		
		{
		    int currentYear = DateTime.Now.Year;                     
			 int obtainedAge = Convert.ToInt32(Console.ReadLine());  
			
			 int age = currentYear - obtainedAge;                    
			 
			 
            Console.WriteLine("You are {0} years old", age);
			 
		
			
		}
	}
}

5. Calculator Age in multiple format

Made by houari lazreg. Source

Enter your birthday: 01/01/2000
your age is:23 years , or 8273 days , or 198545 hours , or 11912693 minutes , or 714761561 seconds
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        { /* My first code in SoloLearn                     #houari-lazreg
        
         This program calculate your age in multiple formats : by years or by days or...by seconds ;-) 
         Don't forget to enter your age with this format : dd/mm/yyyy or this dd-mm-yyyy.*/
        
            DateTime age; Console.WriteLine("Enter your birthday:"); age = Convert.ToDateTime( Console.ReadLine()); int year = Convert.ToInt32( DateTime.Now.Subtract(age).TotalDays/365); int day = Convert.ToInt32(DateTime.Now.Subtract(age).TotalDays); int hour = Convert.ToInt32(DateTime.Now.Subtract(age).TotalHours); int minute = Convert.ToInt32(DateTime.Now.Subtract(age).TotalMinutes); int second = Convert.ToInt32(DateTime.Now.Subtract(age).TotalSeconds); Console.WriteLine("your age is:" + year + " years"+" , or " + day +" days" +" , or " + hour + " hours" +" , or " + minute + " minutes" + " , or " + second + " seconds"); Console.ReadKey();
        }
    }
}

6. Age Calculator by Drey cole

Made by Drey cole. Source

Enter Birth Year!  
2000
You are 22 years old!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
              int x = 2022;
            
        Console.WriteLine("Enter Birth Year!  ");
        
        int y = Convert.ToInt32(Console.ReadLine());
        
        int z = x - y;
        Console.WriteLine("You are {0} years old!",z);
        }
    }
}