To find the surface area of a sphere. (Qbasic Code)

  • To find the surface area of a sphere. (Qbasic Code)
CLS
INPUT "Enter radius of sphere"; r
LET pie = 3.14
A = 4 * pie * r ^ 2
PRINT "The total surface area of the sphere is"; A
END


  • Using SUB Procedure
DECLARE SUB TSA (r)
CLS
INPUT "Enter radius of the sphere"; r
CALL tsa(r)
END

SUB tsa (r)
LET pie = 3.14
A = 4 * pie * r ^ 2
PRINT "The total surface area of the sphere is"; A
END SUB


  • Using FUNCTION Procedure
DECLARE FUNCTION TSA (r)
CLS
INPUT "Enter radius of the sphere"; r
PRINT "The total surface area of the sphere is"; TSA(r)
END

FUNCTION TSA (r)
LET pie = 3.14
A = 4 * pie * r ^ 2
TSA = A
END FUNCTION

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.