**Prerequisite **– PL/SQL introduction

In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.

Given distance in kilometres and task is to convert it into meters and centimeters.

**Examples:**

Input: KM = 10 Output: 10 KM is equivalent to 10000 meters 10 KM is equivalent to 1000000 centimeters Input: KM = 2.5 Output: 2.5 KM is equivalent to 2500 meters 2.5 KM is equivalent to 250000 centimeters

**Approach** is to multiply the KM data with 1000 for converting into meter and with 100000 for converting into centimeter.

Below is the required implementation:

`--DECLARATION SECTION ` `DECLARE` ` ` `--VARAIBLE DECLARATION -KM, MET, CEM; ` ` ` `km NUMBER := 6.9; ` ` ` `met NUMBER := 0; ` ` ` `cem NUMBER := 0; ` `--CODE BLOCK ` `BEGIN` ` ` `--CALCULATE METERS ` ` ` `met := km * 1000; ` ` ` ` ` `--CALCULATE CENTIMETERS ` ` ` `cem := met * 100; ` ` ` ` ` `--DISPLAY RESULT ` ` ` `dbms_output.Put_line(` `'6.9KM is equivalent to meters: '` `||met); ` ` ` ` ` ` ` `dbms_output.Put_line(` `'6.9KM is equivlent to centimeters:'` `||cem); ` ` ` `END` `; ` `--END PROGRAM ` |

*chevron_right*

*filter_none*

**Output : **

6.9KM is equivalent to meters: 6900 6.9KM is equivlent to centimeters:690000

## Recommended Posts:

- PLSQL | CONVERT Function
- Difference between SQL and PLSQL
- PLSQL | LOG Function
- PLSQL | INSTR Function
- PLSQL | INSTRB Function
- PLSQL | LENGTH2 Function
- PLSQL | SOUNDEX Function
- PLSQL | ASCII Function
- PLSQL | CONCAT Function
- PLSQL | COMPOSE Function
- PLSQL | CHR Function
- PLSQL | ASCIISTR Function
- PLSQL : || Operator
- PLSQL | DECOMPOSE Function
- PLSQL | DUMP Function
- PLSQL | INITCAP Function
- PLSQL | LENGTHC Function
- PLSQL | LENGTHB Function
- PLSQL | LENGTH4 Function
- PLSQL | LENGTH Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.