Convert distance from km to meters and centimeters in PL/SQL
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.
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:
Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course by GeeksforGeeks.
6.9KM is equivalent to meters: 6900 6.9KM is equivalent to centimeters:690000