Saturday, October 22, 2016

Qbasic Program: Convert Kilometer to meter



67. Input days and convert into years, months and days.

REM PROGRAM TO INPUT DAYS AND CONVERT INTO YEARS, MONTHS AND DAYS
CLS
INPUT “ENTER DAYS”; D
Y = D \ 365
MO = D MOD 365
M = MO \ 30
D = MO MOD 30
PRINT Y; “YEARS ” ; M; “MONTHS”; D; “DAYS”
END
USING SUB PROCEDURE
DECLARE SUB CONVERT(D)
CLS
INPUT “ENTER DAYS”; D
CALL CONVERT(D)
END
SUB CONVERT (D)
Y = D \ 365
MO = D MOD 365
M = MO \ 30
D = MO MOD 30
PRINT Y; “YEARS ” ; M; “MONTHS”; D; “DAYS”
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(D)
COMMON SHARED Y, M
CLS
INPUT “ENTER DAYS”; D
DD = CONVERT (D)
PRINT Y; “YEARS ” ; M; “MONTHS”; DD; “DAYS”
END
FUNCTION CONVERT (D)
Y = D \ 365
MO = D MOD 365
M = MO \ 30
D S= MO MOD 30
CONVERT = DS
END FUNCTION



68. Input seconds and convert into hours minutes and seconds.
REM PROGRAM TO INPUT SECONDS AND CONVERT INTO HOURS AND MINUTES AND SECONDS
CLS
INPUT “ENTER TIME IN SECONDS”; S
H = S \ 3600
MI = S MOD 3600
M = MI \ 60
S = MI MOD 60
PRINT H; “HOURS”; M; “MINUTES”;  S; “SECONDS”
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(S)
CLS
INPUT “ENTER TIME IN SECONDS”; S
CALL CONVERT(S)
END
SUB CONVERT (S)
H = S \ 3600
MI = S MOD 3600
M = MI \ 60
S = MI MOD 60
PRINT H; “HOURS”; M; “MINUTES”;  S; “SECONDS”
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(S)
COMMON SHARED H, M
CLS
INPUT “ENTER TIME IN SECONDS”; S
SS = CONVERT (S)
PRINT H; “HOURS”; M; “MINUTES”;  SS; “SECONDS”
END
FUNCTION CONVERT (S)
H = S \ 3600
MI = S MOD 3600
M = MI \ 60
S E= MI MOD 60
CONVERT = SE
END FUNCTION


69. Input distance in kilometer and convert into
meter.
REM PROGRAM TO CONVERT KILOMETER TO METER
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
M = K * 1000
PRINT “DISTANCE IN METER=”; M
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(K)
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
CALL CONVERT(K)
END

SUB CONVERT (K)
M = K * 1000
PRINT “DISTANCE IN METER=”; M
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(K)
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
PRINT “DISTANCE IN METER=”; CONVERT(K)
END

FUNCTION CONVERT (K)
M = K * 1000
CONVERT = M
END FUNCTION












70. Input distance in meter and convert into kilometer and meter.
REM PROGRAM TO CONVERT METER TO KILOMETER
CLS
INPUT”ENTER DISTANCE IN METER”; M
K = M \ 1000
MM = M MOD 1000
PRINT K; “KILOMETER”; MM; “METER”
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(M)
CLS
INPUT”ENTER DISTANCE IN METER”; M
CALL CONVERT(M)
END

SUB CONVERT (M)
K = M \ 1000
MM = K MOD 1000
PRINT K; “KILOMETER”; MM; ”METER”
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(M)
COMMON SHARED K
CLS
INPUT”ENTER DISTANCE IN METER”; M
KK = CONVERT(M)
PRINT K; “KILOMETER”; KK; ”METER”
END

FUNCTION CONVERT (M)
K = M \ 1000
MM = K MOD 1000
CONVERT = MM
END FUNCTION




71. Input distance in kilometer and convert into miles.
REM PROGRAM TO CONVERT KILOMETER TO MILES
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
M = K * 0.62
PRINT “DISTANCE IN MILES=”; M
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(K)
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
CALL CONVERT(K)
END

SUB CONVERT (K)
M = K * 0.62
PRINT “DISTANCE IN MILES=”; M
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(K)
CLS
INPUT”ENTER DISTANCE IN KILOMETER”; K
PRINT “DISTANCE IN MILES=”; CONVERT(K)
END

FUNCTION CONVERT (K)
M = K * 0.62
CONVERT = M
END FUNCTION













72. Input value in kilogram and convert into grams.
REM PROGRAM TO CONVERT VALUE IN KILOGRAM TO GRAMS
CLS
INPUT”ENTER VALUE IN KILOGRAM”; K
G = K * 1000
PRINT “VALUE IN GRAMS=”; G
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(K)
CLS
INPUT”ENTER VALUE IN KILOGRAM”; K
CALL CONVERT(K)
END

SUB CONVERT (K)
G = K * 1000
PRINT “VALUE IN GRAMS=”; G
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(K)
CLS
INPUT”ENTER VALUE IN KILOGRAM”; K
PRINT “VALUE IN GRAMS=”; CONVERT(K)
END

FUNCTION CONVERT (K)
G = K * 1000
CONVERT = G
END FUNCTION













73. Input value in meter and convert into inch.
REM PROGRAM TO CONVERT VALUE IN METER TO INCH
CLS
INPUT”ENTER VALUE IN METER”; M
I = M * 39.37
PRINT “VALUE IN INCH=”; I
END

USING SUB PROCEDURE
DECLARE SUB CONVERT(M)
CLS
INPUT”ENTER VALUE IN METER”; M
CALL CONVERT(M)
END

SUB CONVERT (M)
I = M * 39.37
PRINT “VALUE IN INCH=”; I
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION CONVERT(M)
CLS
INPUT”ENTER VALUE IN METER”; M
PRINT “VALUE IN INCH=”; CONVERT(M)
END

FUNCTION CONVERT (M)
I = M * 39.37
CONVERT = I
END FUNCTION




No comments:

Post a Comment