Skip to content

Convert Miles To Inches

Updated: at 02:09 AM

Table of contents

Open Table of contents

Write a program to convert miles to inches

1 mile = 63360 inches

Input  : 5
Output : 316800

C

// Write a C program to convert miles to inches

#include<stdio.h>
int main()
{
    int mile,inch;
    printf("Enter the miles you want to convert:\n");
    scanf("%d",&mile);
    inch=mile*63360;
    printf("%d INCHES\n",inch);
    return 0;
}

C#

// Write a C# program to convert miles to inches

using System;
public class ConvertMilesToInches
{
 public static void Main(string[] args)
    {
      if (args.Length == 0)
	    {
		    Console.WriteLine("Invalid args");
		    return;
	    }
        int miles = Int32.Parse( args[0]);
        Console.WriteLine(miles * 63360);
    }
}

C++

// Write a C++ program to convert miles to inches

#include <iostream>

int main() {
    double miles;
    std::cin >> miles;
    std::cout << miles * 63360 << std::endl;
    return 0;
}

F#

// Write a F# program to convert miles to inches

let milesToInches miles : int =
  miles * 63360

let inches =  milesToInches 5

printfn "Equivalent inches : %d" inches

Go

// Write a Go program to convert miles to inches

package main

import "fmt"

func main() {
	var miles int
	fmt.Scanf("%d", &miles)
	inches := 63360 * miles
	fmt.Println(inches)
}

Haskell

-- Write a Haskell program to convert miles to inches

main :: IO ()
main = do
   putStrLn "Enter miles: "
   input1 <- getLine
   let miles = read input1 :: Float

   let inches = miles * 63360
   putStrLn $ show (inches)

Java

// Write a Java program to convert miles to inches

import java.util.Scanner;

public class ConvertMilesToInches {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int miles;
        int inches;

        System.out.print("Input: ");
        miles = input.nextInt();

        input.close();

        inches = miles * 63360;

        System.out.printf("Output: %d", inches);
        System.out.println();
    }
}

JavaScript

// Write a JavaScript program to convert miles to inches

function ConvertMilesToInches(miles) {
  return miles * 63360;
}

console.log("5 miles is", ConvertMilesToInches(5), "inches");

Julia

# Write a Julia program to convert miles to inches

println("Enter value in miles: ")
miles = readline()
miles = parse(Float64, miles)
inches = round((miles * 63360); digits=2)
println(miles, " miles equals ", inches, " inches")

Kotlin

// Write a Kotlin program to convert miles to inches

import java.util.Scanner

fun main() {
    print("Enter String : ")
    println()
    var min = readLine()

    println("$min miles into inches = " + ConvertMilesToInches(min!!.toDouble()))

}

private fun ConvertMilesToInches(miles: Double): Double {
    var inches = miles * 63360

    return inches
}

Perl

# Write a Perl program to convert miles to inches

#!/usr/bin/perl
use warnings;
use strict;
print "Enter the miles : ";
my $miles = <STDIN>;
my $inches = $miles * 63360;
print $miles." miles is ".$inches." inches", "\n";

PHP

// Write a PHP program to convert miles to inches

<?php
	$x = readline('Enter Miles: ');

  $x1 = $x * 63360;
  echo "Inches: $x1 \n";
?>

Python

# Write a Python program to convert miles to inches

length = int(input("Input distance in miles: "))
d_inches = length * 63360

print("The distance in inches is %i inches." % d_inches)

R

# Write a R program to convert miles to inches

miles = 5
inches = miles * 63360
cat("inches: ", inches)

Ruby

# Write a Ruby program to convert miles to inches

print "Input: "

miles = gets.chomp.to_i
inches = miles * 63360

puts "Output: #{inches}"

Scala

// Write a Scala program to convert miles to inches

object HelloWorld {
	def main(args: Array[String]): Unit = {
	  val miles = scala.io.StdIn.readDouble();
	  println("Inches: " + miles * 63360)
	}
}

Swift

// Write a Swift program to convert miles to inches

import Swift
import Foundation

var miles = 5

var inches = miles * 63360
print("Inches: ", inches)

TypeScript

// Write a TypeScript program to convert miles to inches

/**
 * 1 mile = 63360 inches
 * @param {number} miles
 * @returns {number} converstion of miles to inches
 */

const ONE_MILE_PER_INCH: number = 63360;

export function convertMilesToInches(miles: number): number {
  return miles * ONE_MILE_PER_INCH;
}

Similar programs