将厘米转换为英尺和英寸的程序

在本文中,我们将学习如何将以厘米为单位的高度转换为以英尺和英寸为单位的高度。 例如:

null
Input : centimeter = 10Output : inches = 3.94         feet = 0.33Input : centimeter = 85Output : inches = 33.46         feet = 2.79

我们知道1英寸等于2.54厘米,所以1厘米等于0.3937英寸。因此 n厘米等于(n*0.3937)英寸 . 我们也知道1英尺等于30.48厘米,因此1厘米等于0.0328英尺。所以 n厘米等于(n*0.0328)英尺 .

C++

// C++ program to convert Centimeter to Feet and Inches
#include <iostream>
using namespace std;
// Function to perform conversion
void conversion( int centimeter)
{
double inches = 0.3937 * centimeter;
double feet = 0.0328 * centimeter;
// Printing the output
cout << "Inches is: " << inches << "" ;
cout << "Feet is: " << feet<< "" ;
}
// Driver Code
int main()
{
int centimeter = 10;
conversion(centimeter);
}
/*This code is contributed by Gunjan Gupta.*/


JAVA

// Java program to convert
// centimeter to feet and Inches
import java.io.*;
class GFG {
// Function to perform conversion
static double Conversion( int centi)
{
double inch = 0.3937 * centi;
double feet = 0.0328 * centi;
System.out.printf( "Inches is: %.2f " , inch);
System.out.printf( "Feet is: %.2f" , feet);
return 0 ;
}
// Driver Code
public static void main(String args[])
{
int centi = 10 ;
Conversion(centi);
}
}
/*This code is contributed by Nikita Tiwari.*/


Python3

# Python program to convert centimeter to feet and
# Inches Function to perform conversion
def Conversion(centi):
inch = 0.3937 * centi
feet = 0.0328 * centi
print ( "Inches is:" , round (inch, 2 ))
print ( "Feet is:" , round (feet, 2 ))
# Driver Code
centi = 10
Conversion(centi)


C#

// C# program to convert
// centimeter to feet and Inches
using System;
class GFG {
// Function to perform conversion
static double Conversion( int centi)
{
double inch = 0.3937 * centi;
double feet = 0.0328 * centi;
Console.WriteLine( "Inches is: " + inch);
Console.WriteLine( "Feet is: " + feet);
return 0;
}
// Driver Code
public static void Main()
{
int centi = 10;
Conversion(centi);
}
}
// This code is contributed by vt_m.


PHP

<?php
// PHP program to convert
// centimeter to feet and Inches
// Function to perform conversion
function Conversion( $centi )
{
$inch = 0.3937 * $centi ;
$feet = 0.0328 * $centi ;
echo ( "Inches is: " . $inch . "" );
echo ( "Feet is: " . $feet );
}
// Driver Code
$centi = 10;
Conversion( $centi );
// This code is contributed by Ajit.
?>


Javascript

<script>
//Program to convert centimeter to feet and Inches
// Function to perform conversion
function Conversion(centi) {
var inch = 0.3937 * centi;
var feet = 0.0328 * centi;
inch=inch.toFixed(2);
feet=feet.toFixed(2);
document.write( "Inches is: " + inch + "<br>" );
document.write( "Feet is: " + feet);
return 0;
}
// Driver Code
centi = 10;
Conversion(centi);
//This code is contributed by simranarora5sos
</script>


输出:

Inches is: 3.94 Feet is: 0.33

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享