• Courses
• Data Structure
• ### QBASIC Program to convert Second into Hour, Minute and remaining Second

Posted on 2021-01-26

Write a QBASIC Program to convert second into hour, minute and second.

Solution:

Simple Program

``````CLS
INPUT "Enter Time in Second : "; s
hr = s \ 3600
min = (s - (3600 * hr)) \ 60
sec = (s - (3600 * hr)) - (min * 60)
PRINT "Hour : "; hr
PRINT "Minute : "; min
PRINT "Second : "; sec
END
``````

Using SUB .... END SUB (Sub Procedure)

``````DECLARE SUB time(s)
CLS
INPUT "Enter Time in Second : "; s
CALL time(s)
END

SUB time (s)
hr = s \ 3600
min = (s - (3600 * hr)) \ 60
sec = (s - (3600 * hr)) - (min * 60)
PRINT "Hour : "; hr
PRINT "Minute : "; min
PRINT "Second : "; sec
END SUB
``````

Using FUNCTION ... END FUNCTION (Function Procedure)

``````
DECLARE FUNCTION time(s)
CLS
INPUT "Enter Time in Second : "; s
t = time(s)
END

FUNCTION time (s)
hr = s \ 3600
min = (s - (3600 * hr)) \ 60
sec = (s - (3600 * hr)) - (min * 60)
PRINT "Hour : "; hr
PRINT "Minute : "; min
PRINT "Second : "; sec
END FUNCTION
``````

545

#### Recent MCQs

 MS-Excel Quick Tip 2 MS-Excel Quick Tip 1 MS-Word Quick Tip 3 MS-Word Quick Tip 2