Tu sa naučíme, ako previesť hodnotu dĺžky, ktorá je uvedená v kilometroch, na dĺžku v centimetroch.
Ak chceme previesť hodnotu Kilometer na hodnotu cm, musíme použiť nasledujúci vzorec:
1 km = 100 000 cm. cm = 100 000 * Kilometer.Program 1: Napíšte program v C na prevod hodnoty dĺžky kilometra na centimetre.
#include int main() { double Kilometer = 4; double centimeter; centimeter = 100000 * Kilometer; printf ('Value of 4 kilometer in Centimeter is:', centimeter); return 0; }
Výkon:
Value of 4 kilometer in Centimeter is: 400000
Program 2: Napíšte program v PHP na prevod hodnoty Kilometer na 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 . ' '); ?>
Výkon:
Value of 10.4 Kilometer in Centimeter is: 1040000
Program 3: Napíšte program v Jave na prevod hodnoty Kilometer na 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); } }
Výkon:
Value in Centimeter is: 200845.70
Program 4: Napíšte program v Pythone na prevod hodnoty Kilometer na 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))
Výkon:
Enter the length in Kilometer: 25 The length in centimeter 2500000.00