Skip to main content

SUB N FUNCTION PROCEDURE

 1.To find the volume of cylinder and volume of hemisphere.

=>USING SUB procedure
DECLARE SUB CYLINDER(R,H)
 DECLARE SUB HEMISPHERE(R)
CLS
INPUT "ENTER RADIUS";R
INPUT "ENTER HEIGHT";H
CALL CYLINDER(R,H)
CALL HEMISPHERE(R)
END

SUB CYLINDER(R,H)
C=22/7*R^2*H
PRINT "VOLUME OF CYLINDER=";C
END SUB


SUB HEMISPHERE(R)
HEM=2/3*22/7*R^3
PRINT "VOLUME OF HEMISPHERE=";HEM
END SUB


 USING FUNCTION procedure
DECLARE FUNCTION CYLINDER(R,H)
 DECLARE FUNCTION HEMISPHERE(R)
CLS
INPUT "ENTER RADIUS";R
INPUT "ENTER HEIGHT";H
PRINT "VOLUME OF CYLINDER=";CYLINDER(R,H)
PRINT "VOLUME OF HEMISPHERE=";HEMISPHERE(R)
END

SUB CYLINDER(R,H)
CYLINDER=22/7*R^2*H
END SUB


SUB HEMISPHERE(R)
HEMISPHERE=2/3*22/7*R^3
END SUB


2. To convert Nepali currency into US dollar.


=>USING SUB procedure
DECLARE SUB DOLLAR(NC)
CLS
INPUT "ENTER NEPALI CURRENCY";NC
CALL  DOLLAR(NC)
END

SUB DOLLAR(NC)
D=NC/100
PRINT "US DOLLAR=";D
END SUB


 USING FUNCTION procedure
DECLARE FUNCTION DOLLAR(NC)
CLS
INPUT "ENTER NEPALI CURRENCY";NC
PRINT "US DOLLAR=";DOLLAR(NC)
END

FUNCTION  DOLLAR(NC)
DOLLAR=NC/100
END FUNCTION


3.Calculate the area of sphere.

=>USING SUB procedure
DECLARE SUB AREA(R)
CLS
INPUT "ENTER RADIUS";R
CALL AREA(R)
END

SUB AREA (R)
A=4*22/7*R^2
PRINT "AREA OF SPHERE=";A
END SUB


=>USING FUNCTION procedure
DECLARE FUNCTION AREA(R)
CLS
INPUT "ENTER RADIUS";R
 PRINT "AREA OF SPHERE=";AREA(R)
END

FUNCTION AREA (R)
AREA=4*22/7*R^2
END FUNCTION



4. To convert US dollar. into Nepali currency


=>USING SUB procedure
DECLARE SUB CURRENCY(D)
CLS
INPUT "ENTER DOLLAR";D
CALL  CURRENCY(D)
END

SUB CURRENCY(D)
NC=D*100
PRINT "NEPALI CURRENCY=";NC
END SUB


 USING FUNCTION procedure
DECLARE FUNCTION CURRENCY(D)
CLS
INPUT "ENTER NEPALI CURRENCY";NC
PRINT "US DOLLAR=";CURRENCY(D)
END

FUNCTION CURRENCY(D)
CURRENCY=D*100
END FUNCTION

 

5.Calculate T.S.A of sphere.


=>USING SUB procedure
DECLARE SUB AREA(R)
CLS
INPUT "ENTER RADIUS";R
CALL AREA(R)
END

SUB AREA (R)
A=3*22/7*r^2
PRINT "AREA OF SPHERE=";A
END SUB


=>USING FUNCTION procedure
DECLARE FUNCTION AREA(R)
CLS
INPUT "ENTER RADIUS";R
 PRINT "AREA OF SPHERE=";AREA(R)
END

FUNCTION AREA (R)
AREA=3*22/7*r^2
END FUNCTION











Comments

Popular posts from this blog

QBASIC Solutions

Q.1) WAP to change degree Celsius into degree Fahrenheit.   => CLS        INPUT "Enter degree celsius value" ; D        F = ( 9 * C / 5 ) + 32        PRINT "Degree Fahrenheit value = "; F        END Q.2) WAP to change dollar into Nepali currency.   => CLS       INPUT "Enter Dollar value"; USD        NRS = USD * 100       PRINT "Nepali currency value = "; NRS       END Q.3) WAP to change Indian currency into Nepali currency. => CLS                   INPUT "Enter Indian currency value"; IC       NRS = IC * 1.6        PRINT "Nepali currency value = "; NRS   ...

17 QBASIC Programming

1. Create a sequential file "std.dat" to store name and marks obtained in English, Math and Science subjects for a few students. (74 set 1) OPEN   “std.dat”   FOR OUTPUT   AS   #1 DO CLS INPUT “Enter name “; N$ INPUT   “Enter English marks”; E INPUT “Enter Math's marks"; M INPUT "Enter Science marks"; S WRITE #1, N$, E, M, S INPUT "Do you want to continue (Y/N)";CH$ LOOP WHILE UCASE$ (CH$) "Y" CLOSE #1 END 4.   WAP to add some more   records in a data file “ABC.DAT” having following fields : patient’s name, address and age.  OPEN   “ABC.DAT”   FOR OUTPUT   AS   #1 DO CLS INPUT “Enter Patients name “; N$ INPUT   “Enter patients address”; A$ INPUT “Enter Patient's age "; A WRITE #1, N$, A$, A INPUT "Do you want to continue (Y/N)";CH$ LOOP WHILE CH$="Y" OR CH$="y" CLOSE #1 END       6.WAP to store records regarding the information of book’s number, name and author’s ...

SLC Examination 2070

SLC Examination 2070 (2014) RE 1. Answer the following questions. a) What is network topology ? Write any one advantage of star topology. => The arrangement or connection pattern of computers or nodes and other devices of the network is called network topology. Advantage of star topology is it is easy to detect errors . b) Give any two advantages of e-mail over traditional mail. => Advantages It is very fast compare to traditional mail. It allows to send and receive message across the world. c) List any two main aims of formulating cyber law in Nepal. => Two main aims of formulating cyber law in Nepal are: Provides punishment who conducts cyber crime Provides legal status for various banking transaction through electronic media, which will be instrumental in boosting economic activities throughout the world via internet. d) Give any two symptoms of virus attack. => Two symptoms of virus attack  Program takes long...