-
Language
C#
-
Description
Age calculation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
namespace AgeCalculation
{
class AgeCalculation
{
static void Main(string[] args)
{
int age, birth_day, birth_month, birth_year, current_day;
int current_month, current_year;
Console.Write("Enter the value of birth day: ");
birth_day = int.Parse(Console.ReadLine());
Console.Write("Enter the value of birth month: ");
birth_month = int.Parse(Console.ReadLine());
Console.Write("Enter the value of birth year: ");
birth_year = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current day: ");
current_day = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current month: ");
current_month = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current year: ");
current_year = int.Parse(Console.ReadLine());
age=current_year-birth_year;
if(birth_month>current_month||(birth_month==current_month&&birth_day>current_day))
age=age-1;
Console.WriteLine("Value of age: " + age);
Console.WriteLine();
Console.Write("Press any key to finish . . . ");
Console.ReadKey();
}
}
}
namespace AgeCalculation
{
class AgeCalculation
{
static void Main(string[] args)
{
int age, birth_day, birth_month, birth_year, current_day;
int current_month, current_year;
Console.Write("Enter the value of birth day: ");
birth_day = int.Parse(Console.ReadLine());
Console.Write("Enter the value of birth month: ");
birth_month = int.Parse(Console.ReadLine());
Console.Write("Enter the value of birth year: ");
birth_year = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current day: ");
current_day = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current month: ");
current_month = int.Parse(Console.ReadLine());
Console.Write("Enter the value of current year: ");
current_year = int.Parse(Console.ReadLine());
age=current_year-birth_year;
if(birth_month>current_month||(birth_month==current_month&&birth_day>current_day))
age=age-1;
Console.WriteLine("Value of age: " + age);
Console.WriteLine();
Console.Write("Press any key to finish . . . ");
Console.ReadKey();
}
}
}