CONVERT DAYS - CONVERT SECONDS - CALCULATE DISTANCE - CONVERT KILOMETER TO METER - CALCULATE SUM OF FIRST N NATURAL MUNBERS
61. 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
62. 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(D)
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 (D)
H = S \ 3600
MI = S MOD 3600
M = MI \ 60
S E= MI MOD 60
CONVERT = SE
END FUNCTION
63. 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
64. 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
63. Calculate distance.[S=UT+1/2(AT2)]
REM CALCULATE DISTANCE
CLS
INPUT “ENTER INITIAL VELOCITY”; U
INPUT “ENTER TIME”; T
INPUT “ENTER ACCELARATION”; A
S = U * T + 1 / 2 * A * T ^ 2
PRINT “DISTANCE TRAVELLED = “; S
END
USING SUB PROCEDURE
DECLARE SUB DISTANCE (U, T, A)
CLS
INPUT “ENTER INITIAL VELOCITY”; U
INPUT “ENTER TIME”; T
INPUT “ENTER ACCELARATION”; A
CALL DISTANCE (U, T, A)
END
SUB DISTANCE (U, T, A)
S = U * T + 1 / 2 * A * T ^ 2
PRINT “DISTANCE TRAVELLED = “; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION DISTANCE (U, T, A)
CLS
INPUT “ENTER INITIAL VELOCITY”; U
INPUT “ENTER TIME”; T
INPUT “ENTER ACCELARATION”; A
PRINT “DISTANCE TRAVELLED = “;DISTANCE (U, T, A)
END
FUNCTION DISTANCE (U, T, A)
DISTANCE = U * T + 1 / 2 * A * T ^ 2
END FUNCTION
64. Calculate potential energy of body. [PE=MGH where G=9.8]
REM CALCULATE POTENTIAL ENERGY OF BODY
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
P = M * 9.8 * H
PRINT “POTENTIAL ENERGY OF BODY”; P
END
USING SUB PROCEDURE
DECLARE SUB CALULATE(M, H)
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
CALL CALULATE (M, H)
END
SUB CALULATE (M, H)
P = M * 9.8 * H
PRINT “POTENTIAL ENERGY OF BODY”; P
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CALCULATE (M, H)
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
PRINT “POTENTIAL ENERGY OF BODY”; CALCULATE (M, H)
END
FUNCTION CALCULATE (M, H)
CALULATE = M * 9.8 * H
END FUNCTION
65. Ask quantity of pen, copy and pencil and their rate and find out the total amount.
REM CALCULATE TOTAL AMOUNT
CLS
INPUT “ENTER QUANTITY OF PEN”;QP
INPUT “ENTER RATE OF PEN”; RP
INPUT “ENTER QUANTITY OF COPY”; QC
INPUT “ENTER RATE OF COPY”; RC
INPUT “ENTER QUANTITY OF PENCIL”; QPC
INPUT” ENTER RATE OF PENCIL”; RPC
TA = (QP * RP) + (QC * RC) + (QPC * RPC)
PRINT “TOTAL AMOUNT =”; TA
END
USING SUB PROCEDURE
DECLARE SUB TOTAL ()
COMMON SHARED QP, RP, QC, RC, QPC, RPC
CLS
INPUT “ENTER QUANTITY OF PEN”;QP
INPUT “ENTER RATE OF PEN”; RP
INPUT “ENTER QUANTITY OF COPY”; QC
INPUT “ENTER RATE OF COPY”; RC
INPUT “ENTER QUANTITY OF PENCIL”; QPC
INPUT” ENTER RATE OF PENCIL”; RPC
CALL TOTAL
END
SUB TOTAL
TA = (QP * RP) + (QC * RC) + (QPC * RPC)
PRINT “TOTAL AMOUNT =”; TA
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION TOTAL ()
COMMON SHARED QP, RP, QC, RC, QPC, RPC
CLS
INPUT “ENTER QUANTITY OF PEN”;QP
INPUT “ENTER RATE OF PEN”; RP
INPUT “ENTER QUANTITY OF COPY”; QC
INPUT “ENTER RATE OF COPY”; RC
INPUT “ENTER QUANTITY OF PENCIL”; QPC
INPUT” ENTER RATE OF PENCIL”; RPC
PRINT “TOTAL AMOUNT =”; TOTAL
END
FUNCTION TOTAL
TA = (QP * RP) + (QC * RC) + (QPC * RPC)
TOTAL = TA
END FUNCTION
66. Input n number and print the sum of first n natural numbers.
REM CALCULATE SUM OF FIRST N NATURAL NUMBERS
CLS
INPUT “ENTER THE NUMBER”; N
S = N * (N + 1) / 2
PRINT “SUM OF”; N; “NUMBERS=”; S
END
USING SUB PROCEDURE
DECLARE SUB SUM(N)
CLS
INPUT “ENTER THE NUMBER”; N
CALL SUM (N)
END
SUB SUM (N)
S = N * (N + 1) / 2
PRINT “SUM OF”; N; “NUMBERS=”; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SUM(N)
CLS
INPUT “ENTER THE NUMBER”; N
PRINT “SUM OF”; N; “NUMBERS=”; SUM (N)
END
FUNCTION SUM (N)
S = N * (N + 1) / 2
SUM = S
END FUNCTION
67. Input n number and print the sum square of first n natural numbers.
REM CALCULATE SUM OF SQUARE OF FIRST N NATURAL NUMBERS
CLS
INPUT “ENTER THE NUMBER”; N
S = N * (N + 1) * (2 * N + 1) / 6
PRINT “SUM OF SQUARE OF ”; N; “NUMBERS=”; S
END
USING SUB PROCEDURE
DECLARE SUB SUMSQ(N)
CLS
INPUT “ENTER THE NUMBER”; N
CALL SUMSQ(N)
END
SUB SUMSQ (N)
S = N * (N + 1) * (2 * N + 1) / 6
PRINT “SUM OF SQUARE OF ”; N; “NUMBERS=”; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SUMSQ(N)
CLS
INPUT “ENTER THE NUMBER”; N
PRINT “SUM OF SQUARE OF ”; N; “NUMBERS=”; SUMSQ (N)
END
FUNCTION SUMSQ (N)
S = N * (N + 1) * (2 * N + 1) / 6
SUMSQ = S
END FUNCTION
Comments
More than 160k men and women are trying a easy and secret "liquids hack" to lose 2 lbs every night in their sleep.
It's simple and it works with anybody.
Here's how you can do it yourself:
1) Go get a drinking glass and fill it half glass
2) Then do this weight loss hack
and be 2 lbs thinner as soon as tomorrow!