Tu se bomo naučili pretvoriti dolžino, podano v centimetrih, v dolžino v čevljih in palcih.
Sledita dve formuli, ki pomagata pretvoriti cm v čevlje in palce:
- 1 palec = 2,54 centimetra
- 1 čevelj = 30,48 centimetra
Iz teh formul najdemo naslednji dve formuli:
samo nick
- palec = 0,3937 * Centimeter (cm)
- čevlji = 0,0328 * Centimeter (cm)
Program 1: Napišite program v C za pretvorbo cm v čevlje in inče.
#include int main() { int centimeter = 40; double inch, feet; inch = 0.3937 * centimeter; feet = 0.0328 * centimeter; printf ('Inches is: %.2f ', inch); printf ('Feet is: %.2f', feet); return 0; }
Izhod:
datumski niz java
Inches is: 15.75 Feet is: 1.31
Program 2: Napišite program v PHP za pretvorbo cm v čevlje in inče.
<?php // This is a PHP program which converts the centimeter length to feet and Inches $cen = 10; $inch = 0.3937 * $cen; $feet = 0.0328 * $cen; echo('Inches is: ' . $inch . ' '); echo('Feet is: ' . $feet); ?>
Izhod:
zakaj je niz nespremenljiv v Javi
Inches is: 3.94 Feet is: 0.33
Program 3: Napišite program v Javi za pretvorbo cm v čevlje in inče.
// This is a Java program which converts centimeter length to feet and Inches import java.io.*; class convert { static double Conversion_length(int centimeter) { double inch, feet; inch = 0.3937 * centimeter; feet = 0.0328 * centimeter; System.out.printf('Inches is: %.2f ', inch); System.out.printf('Feet is: %.2f', feet); return 0; } public static void main(String args []) { int centimeter = 20; Conversion_length(centimeter); } }
Izhod:
Inches is: 7.87 Feet is: 0.656
Program 4: Napišite program v Pythonu za pretvorbo cm v čevlje in inče.
# This is a Python program which converts centimeter length to feet and Inches centimeter=int(input('Enter the height in centimeters:')) #convert centimeter to inches inches = 0.394 * centimeter #convert centimeter to feet feet = 0.0328 * centimeter print('The length in feet',round(feet,2)) print('The length in inches',round(inches,2))
Izhod:
Enter the height in centimeters: 167 The length in feet 5.48 The length in inches 65.8