Selasa, 24 September 2013

Length Conversion Program ( Pascal )
Algorithms and Programming
Length Conversion Program

This time we will create a program to convert units of length , this time from centimeters ( cm ) into units of meters ( m ) and decimetre ( dm ) .
Just like the previous conversion program , we need to do is make the first algorithm . But be sure to understand the form of program that we will create . This program is actually much easier than the previous program because we do not need to use mod and div functions . Before making a program , we need to look at the work that we want from the program . Ie like this :

... cm = ... m = ... dm
Of that form, we can immediately understand what form of program as desired . Before making a program , we need to seek first the conversion of each - each unit . First , we find the conversion from cm to m and conversion from cm to dm . In the elementary school we would have learned it? ? ? ? so i ga have tired - tired ngejelasinnya again ... that we know , 1 cm = 1/100 m or in other words , 1cm = 0.01m and 1 cm = 1/10 dm or in other words , 1cm = 0.1m .

That way , we can immediately make pseudocodenya as follows :

algorithm Program_Konversi_Panjang
{ I.S : Number of units in cm filled }
{ F.S : conversion results in dm and m found }

Declaration
cm , dm , m : real ;

algorithm
write (' Enter the number of units ( cm ) = ' ) ;
input ( cm ) ;

m < = cm * 0:01 ; } { 1cm = 1/100m
dm < = cm * 0.1 ; } { 1cm = 1/10dm

write ( cm : 0:0 , ' cm = ' , dm : 0:2 , ' dm ' ) ;
write ( ' = ' , m : 0:2 , ' m ' ) ;

From the pseudocode above , we can write the syntax in the dev - pascal program like this ( my version ) :

programKonversi_Panjang ;
{ I.S : Number of units in cm filled }
{ F.S : conversion results in dm and m found }
var
cm , dm , m : real ;
begin
/ / INPUT Number of units in cm
writeln ( ' Conversion Program Length ' ) ;
writeln ( ' ----------------------------------------------- --------------------------------- ' ) ;
write (' Enter the number of units ( cm ) = ' ) ; readln ( cm ) ;
/ / CALCULATE conversion from cm to m and dm
m : = cm * 0:01 ; } { 1cm = 1/100m
dm : = cm * 0.1 ; } { 1cm = 1/10dm
/ / SHOW results of conversion
writeln ( ' ----------------------------------------------- --------------------------------- ' ) ;
writeln ( ' Press ENTER to see the results of conversion ' ) ; readln ;
write ( cm : 0:0 , ' cm = ' , dm : 0:2 , ' dm ' ) ;
write ( ' = ' , m : 0:2 , ' m ' ) ;
readln ;
end .

Once we compile the program then we will get a result like this :

Figure 1 . Length conversion program results

Then to test it , let us enter the value length ( cm ) that we want to convert . Then it will be look like this :


That way we managed again to create a simple program using Pascal .... # JENGJENGJENG .. * jump while wearing styles DORA *

So first post this time ... modem already protested ya , , , from life to death was merely the connection .... - .. -

Tidak ada komentar:

Posting Komentar