Full width home advertisement

Grade 10 Revision

Post Page Advertisement [Top]

QBASIC SUB Procedure Practial Exam Important Questions

a) To display area of four walls (Hint: A=2H(L+B)
Ans.
DECLARE SUB AREA(L,B,H)
INPUT"ENTER LENGTH,BREADTH,HEIGHT"; L,B,H
CALL AREA (L,B,H)
END
SUB AREA(L,B,H)
A=2*H*(L+B)
PRINT"THE AREA OF FOUR WALLS IS";A
END SUB


b) To find area of circle
DECLARE SUB AREA(R)
INPUT"ENTER THE RADIUS "; R
CALL AREA (R)
END
SUB AREA(RR)
A=22/7*R^2
PRINT"THE AREA CIRCLE IS";A
END SUB

c) Write a program to test whether the given number is positive or negative using SUB……END SUB
DECLARE SUB TEST(N)
CLS
INPUT “Enter a number”; N
CALL TEST(N)
END
SUB TEST(N)
IF N>0 THEN
PRINT N; “is positive number”
ELSE
PRINT N; “is negative number”
END IF
END SUB

d) To display largest number among three different numbers
DECLARE SUB COMPARE(A,B,C)
CLS
INPUT" ENTER THE THREE NUMBERS"; A,B,C
CALL COMPARE (A,B,C)
END
SUB COMPARE( A,B,C)
IF A>B AND A>C THEN
PRINT"THE LARGEST NUMBER IS"; A
ELSEIF B>A AND B>C THEN
PRINT" THE LARGEST NUMBER IS";B
ELSE
PRINT"THE LARGEST NUMBER IS";C
END IF
END SUB

e) To check even or odd number
DECLARE SUB TEST(N)
CLS
INPUT “Enter a number”; N
CALL TEST(N)
END
SUB TEST(N)
IF N MOD 2 =0 THEN
PRINT N; “is EVEN number”
ELSE
PRINT N; “is ODD number”
END IF
END SUB


f) To display multiplication table of a given number
DECLARE SUB MUL(N)
CLS
INPUT "Enter any number"; N
CALL MUL(N)
END
SUB MUL(N)
FOR i = 1 TO 10
a = n * i
PRINT n; "x"; i; "="; a
NEXT i
END SUB


g) WAP to find the sum of individual digits of a multidigit number using SUB...END...SUB
DECLARE SUB SUM (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL SUM (N)
END

SUB SUM (N)
S = 0
WHILE N < > 0
R = N MOD 10
S = S + R
N = N \ 10
WEND
PRINT "SUM OF DIGITS"; S
END SUB


h) Write a program to print the natural numbers from 1 to 5 using SUB…END SUB.
Ans: DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 5
PRINT I
NEXT I
END SUB



i) Write a program using SUB….END SUB to get radius of circle and then print its circumference.
Ans: DECLARE SUB CIRC(R)
CLS
CONST PI=3.1416
INPUT ”Enter radius”; R
CALL CIRC(R)
END

SUB CIRC(R)
C=2*PI*R
PRINT “The circumference of circle=”;C
END SUB


j) Write a program using Sub….End Sub to get a word from the user and then print it in reverse order.
Ans: DECLARE SUB REV (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL REV(S$)
END

SUB REV (S$)
FOR I = LEN(S$) TO 1 STEP -1
B$ = MID$(S$, I, 1)
W$ = W$ + B$
NEXT I
PRINT "REVERSED STRING IS "; W$
END SUB



j) Write a program using sub procedure module to print the series 1,1,2,3,5,8.. up to ten terms.
Ans: DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES ( )
A = 1
B = 1
FOR I = 1 TO 10
PRINT A;
C = A + B
A = B
B = C
NEXT I
END SUB



1 comment:

  1. Hi All!

    We are selling fresh & genuine SSN Leads, with good connectivity. All data is tested & verified.
    Headers in Leads:

    First Name | Last Name | SSN | Dob | Address | State | City | Zip | Phone Number | Account Number | Bank Name | DL Number | Routing Number | IP Address | Reference | Email | Rental/Owner |

    *You can ask for sample before any deal
    *Each lead will be cost $1
    *Premium Lead will be cost $5
    *If anyone wants in bulk I will negotiate
    *Sampling is just for serious buyers

    Hope for the long term deal
    For detailed information please contact me on:

    Whatsapp > +923172721122
    email > leads.sellers1212@gmail.com
    telegram > @leadsupplier
    ICQ > 752822040

    ReplyDelete

Bottom Ad [Post Page]