Pages

Write A programme c# that calculate Age Difrence in Two Persons.

INPUT:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace age_difference
{
    class Program
    {
        static void Main(string[] args)
        {
            int age1, age2, difference;
            Console.WriteLine("Enter age 1");
            age1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter age 2");
            age2 = Convert.ToInt32(Console.ReadLine());
            difference = age1 - age2;


            if (difference < 0)
            {
                difference = difference * (-1);
                Console.WriteLine(" age difference IS {0}", difference);
            }
            else
            {
                Console.WriteLine("age difference is {0}", difference);
            }
        }
    }
}                                                                 

OUTPUT:

No comments:

Post a Comment