Tukaj se bomo naučili, kako pretvoriti vrednost dolžine, ki je podana v kilometrih, v dolžino v centimetrih.
Če želimo vrednost kilometra pretvoriti v vrednost v cm, moramo uporabiti naslednjo formulo:
1 km = 100000 cm. cm = 100000 * Kilometer.Program 1: Napišite program v C za pretvorbo vrednosti dolžine kilometra v centimeter.
#include int main() { double Kilometer = 4; double centimeter; centimeter = 100000 * Kilometer; printf ('Value of 4 kilometer in Centimeter is:', centimeter); return 0; }
Izhod:
Value of 4 kilometer in Centimeter is: 400000
Program 2: Napišite program v PHP za pretvorbo vrednosti kilometra v cm.
<?php // This is a PHP program which converts the value of Kilometer into the value of cm $Kilometer = 10.4; $centimeter = 100000 * $Kilometer; echo('Value of 10.4 Kilometer in Centimeter is ' . $centimeter . ' '); ?>
Izhod:
Value of 10.4 Kilometer in Centimeter is: 1040000
Program 3: V Javi napišite program za pretvorbo vrednosti kilometra v cm.
// This is a Java program which converts the value of Kilometer into the value in cm import java.io.*; class convert { static double Conversion_Kilometer_to_cm(int Kilometer) { double centimeter; centimeter = 100000 * Kilometer; System.out.printf('Value in Centimeter is: %.2f ', centimeter); return 0; } public static void main(String args []) { int Kilometer = 2.008457; Conversion_Kilometer_to_cm(Kilometer); } }
Izhod:
Value in Centimeter is: 200845.70
Program 4: V Pythonu napišite program za pretvorbo vrednosti kilometra v cm.
# This is a Python program which converts the value of Kilometer into cm Kilometer=int(input('Enter the length in Kilometer:')) #convert Kilometer to cm centimeter = 100000 * Kilometer; print('The length in centimeter',round(centimeter,2))
Izhod:
Enter the length in Kilometer: 25 The length in centimeter 2500000.00