April 23, 2020

Write a C# program that accepts distance in kilometers and converts it into meters.

Write a C# program that accepts distance in kilometers, converts it into meters, and then displays the result.

Write a C# program that accepts distance in kilometers and converts it into meters.

Sample Solution

C# Sharp Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Meter_Kilometer
    {
        static void Main(string[] args)
        {
            int distance, Result;
            Console.WriteLine("Enter the distance in Kilometers");
            distance = Convert.ToInt32(Console.ReadLine());
            Result = distance * 1000;
            Console.WriteLine(" Distance in meters:" + Result);
            Console.ReadLine();

        }

    }
}
Sample Output
Write a C# program that accepts distance in kilometers and converts it into meters.



No comments:

Post a Comment