logo

Програм за претварање цм у стопе и инче

Овде ћемо научити како да конвертујемо дужину, која је дата у центиметрима, у дужину у стопама и инчима.

Следе две формуле које помажу у претварању цм у стопе и инче:

инт у низ
  1. 1 инч = 2,54 центиметра
  2. 1 стопа = 30,48 центиметара

Из ових формула налазимо следеће две формуле:

  1. инч = 0,3937 * центиметар (цм)
  2. стопа = 0,0328 * центиметар (цм)

Програм 1: Напишите програм у Ц за претварање цм у стопе и инче.

 #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; } 

Излаз:

алгоритми претраживања
 Inches is: 15.75 Feet is: 1.31 

Програм 2: Напишите програм у ПХП-у за претварање цм у стопе и инче.

 <?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); ?> 

Излаз:

јава датум актуелни
 Inches is: 3.94 Feet is: 0.33 

Програм 3: Напишите програм у Јави за претварање цм у стопе и инче.

 // 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(&apos;Inches is: %.2f 
&apos;, inch); System.out.printf(&apos;Feet is: %.2f&apos;, feet); return 0; } public static void main(String args []) { int centimeter = 20; Conversion_length(centimeter); } } 

Излаз:

 Inches is: 7.87 Feet is: 0.656 

Програм 4: Напишите програм у Питхон-у за претварање цм у стопе и инче.

 # This is a Python program which converts centimeter length to feet and Inches centimeter=int(input(&apos;Enter the height in centimeters:&apos;)) #convert centimeter to inches inches = 0.394 * centimeter #convert centimeter to feet feet = 0.0328 * centimeter print(&apos;The length in feet&apos;,round(feet,2)) print(&apos;The length in inches&apos;,round(inches,2)) 

Излаз:

 Enter the height in centimeters: 167 The length in feet 5.48 The length in inches 65.8