C# Function that converts inches to centimetre.

/* C# Function that converts inches to centimetre. */
using System;
public class Demo
{
    public static float convert(float a)
    {
        float cm1;
        cm1 = (float)(a * 2.54);
        return cm1;
    }

    public static void Main(string[] args)
    {
        float inch, cm;
        Console.WriteLine("Enter value in Inch : ");
        inch = float.Parse(Console.ReadLine());
        cm = convert(inch);
        Console.WriteLine("{0} inch is equal to {1} centimeter ", inch, cm);
        Console.ReadLine();
    }
}

Output :
Enter value in Inch :
50

50.00 inch is equal to 127.00 centimeter



Leave a comment