0% found this document useful (0 votes)
297 views12 pages

QBASIC PROGRAMS For SEE Appearing Students &#8211 SET 2 PDF

Uploaded by

Uday Poudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
297 views12 pages

QBASIC PROGRAMS For SEE Appearing Students &#8211 SET 2 PDF

Uploaded by

Uday Poudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 1

Share on Facebook Share


Share on TwitterTweet
Share on Google Plus Share
Share on LinkedIn Share
Print This Page
Questions are taken from Brush-up Computer Science Book
[Benchmark Publication ]
1. Write a program to find area of four walls.
Using Function Procedure:

DECLARE FUNCTION AREA(L,B,H)

CLS

INPUT “ENTER LENGTH” ; L

INPUT “ENTER BREADTH” ; B

INPUT “ENTER HEIGHT” ; H

PRINT “THE AREA OF FOUR WALLS= ” ; AREA(L,B,H)

END

FUNCTION AREA(L,B,H)

AREA=2*H*(L+B)

END FUNCTION

Using SUB Procedure

DECLARE SUB AREA(L,B,H)

CLS

INPUT “ENTER LENGTH” ; L

INPUT “ENTER BREADTH” ; B

INPUT “ENTER HEIGHT” ; H

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 2

CALL AREA(L,B,H)

END

SUB AREA(L,B,H)

A=2*H*(L+B)

PRINT “AREA IS “; A

END FUNCTION

2. Write a program to define a function procedure that returns simple interest.

Using FUNCTION Procedure :

DECLARE FUNCTION SI(P,T,R)

CLS

INPUT “ENTER PRINCIPLE” ; P

INPUT “ENTER TIME” ; T

INPUT “ENTER RATE” ; R

PRINT “SIMPLE INTEREST IS = ” ;SI(P,T,R)

END

FUNCTION SI(P,T,R)

SI=(P*T*R)/100

END FUNCTION

Using SUB Procedure :

DECLARE SUB SI(P,T,R)

CLS

INPUT “ENTER PRINCIPLE” ; P

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 3

INPUT “ENTER TIME” ; T

INPUT “ENTER RATE” ; R

CALL SI(P,T,R)

END

SUB SI(P,T,R)

I=(P*T*R)/100

PRINT “INTEREST IS ” ; I

END SUB

3. Write a program to convert the supplied Nepalese currency into its


equivalent Indian currency.

Using FUNCTION Procedure :

DECLARE FUNCTION CONV(N)

CLS

INPUT “ENTER NEPALESE CURRENCY ” ; P

PRINT “INDIAN CURRRENCY = ” ;CONV(P)

END

FUNCTION CONV(P)

CONV=P/1.6

END FUNCTION

Using SUB Procedure:

DECLARE SUB CONV(N)


CLS

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 4

INPUT “ENTER NEPALESE CURRENCY ” ; P

CALL CONV(P)

END

SUB CONV(P)

C=P/1.6

PRINT “INDIAN CURRENCY “; C

END SUB

4. Write a program to check whether an input number is even or odd.

Using Function Procedure:

DECLARE FUNCTION CONV$(N)

CLS

INPUT “ENTER A NUMBER ” ; P

PRINT CONV$(P)

END

FUNCTION CONV$(P)

IF P MOD 2 = 0 THEN

CONV$=”EVEN NUMBER”

ELSE

CONV$=”ODD NUMBER”

ENDIF

END FUNCTION

Using SUB Procedure:

DECLARE SUB CONV(P)

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 5

CLS

INPUT “ENTER A NUMBER ” ; P

CALL CONV(P)

END

SUB CONV(P)

IF P MOD 2 = 0 THEN

PRINT “EVEN NUMBER”

ELSE

PRINT “ODD NUMBER”

ENDIF

END SUB

5. Write a program to check whether the input number is divisible by 4 and 6


or not.

Using Function Procedure:

DECLARE FUNCTION CHECK$(N)

CLS

INPUT “ENTER A NUMBER ” ; P

PRINT CHECK$(P)

END

FUNCTION CHECK$(P)

IF P MOD 4 =0 AND P MOD 6=0 THEN

CHECK$=”DIVISIBLE BY BOTH NUMBERS”

ELSE

CONV$=”NOT DIVISIBLE BY BOTH NUMBERS”

ENDIF

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 6

END FUNCTION

Using Sub Procedure:

DECLARE SUB CHECK(N)

CLS

INPUT “ENTER A NUMBER ” ; P

CALL CHECK(P)

END

SUB CHECK(P)

IF P MOD 4 =0 AND P MOD 6=0 THEN

PRINT “DIVISIBLE BY BOTH NUMBERS”

ELSE

PRINT “NOT DIVISIBLE BY BOTH NUMBERS”

ENDIF

END SUB

6. Write a program to calculate the square of all digits of input number.

Using Function Procedure:

DECLARE FUNCTION SQU(A)

CLS

INPUT “ENTER A NUMBER” ; N

PRINT SQU(N)

FUNCTION SQU(N)

WHILE N<>0

R=N MOD 10

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 7

S=R^2

PRINT S

N=N\10

WEND

END DUNCTION

Using Sub Procedure :

DECLARE SUB SQU(A)

CLS

INPUT “ENTER A NUMBER” ; N

CALL SQU(N)

END

SUB SQU(N)

WHILE N<>0

R=N MOD 10

S=R^2

PRINT S

N=N\10

WEND

END SUB

7. Write a program to calculate the circumference of circle.

Using Function Procedure:

DECLARE FUNCTION CIR(A)

CLS

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 8

INPUT “ENTER RADIUS OF A CIRCLE”; R

PRINT “CIRCUMFERENCE IS” ; CIR(R)

END

FUNCTION CIR(A)

P=3.14

CIR=2*P*A

END FUNCTION

Using SUB Procedure:

DECLARE SUB CIR(A)

CLS

INPUT “ENTER RADIUS OF A CIRCLE”; R

CALL CIR(R)

END

SUB CIR(A)

P=3.14

C=2*P*A

PRINT “CIRCUMFERENCE IS ” ; C

END SUB

8. Write a program to display the reverse of input string .

Using Function Procedure

DECLARE FUNCTION REV$(N$)

CLS

INPUT “ENTER A STRING” ; W$

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 9

PRINT “REVERSED STRING::”;REV$(W$)

END

FUNCTION REV$(N$)

FOR I = LEN(N$) TO 1 STEP -1

D$=D$+MID$(N$,I,1)

NEXT I

REV$=D$

END FUNCTION

Using SUB Procedure:

DECLARE SUB REV(N$)

CLS
INPUT “ENTER A WORD” ; W$

CALL REV(W$)

END

SUB REV(N$)
FOR I = LEN(N$) TO 1 STEP-1
C$=C$+MID$(N$,I,1)

NEXT I

PRINT “REVERSED STRING” ; C$

END SUB

9. Write a program that accepts three different numbers and returns the
smallest one.

Using Function Procedure:

DECLARE FUNCTION SMALL(A,B,C)

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 10

CLS

INPUT “ENTER FIRST NUBER” ; A

INPUT “ENTER SECOND NUMBER” ; B

INPUT “ENTER THIRD NUMBER” ; C

PRINT “THE SMALLEST NUMBER IS” ; SMALL(A,B,C)

FUNCTION SMALL(A,B,C)

IF A<B AND B<C THEN

SMALL=A

ELSE IF B<A AND A<C THEN

SMALL=B

ELSE

SMALL=C

END FUNCTION

Using SUB Procedure:

DECLARE SUB SMALL(A,B,C)

CLS

INPUT “ENTER FIRST NUBER” ; A

INPUT “ENTER SECOND NUMBER” ; B

INPUT “ENTER THIRD NUMBER” ; C

CALL SMALL(A,B,C)

FUNCTION SMALL(A,B,C)

IF A<B AND B<C THEN

PRINT “SMALLEST” ; A

ELSE IF B<A AND A<C THEN

PRINT “SMALLEST” ; B

ELSE

PRINT “SMALLEST” ; C

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 11

END SUB

10. WAP to find whether the first character of the input string is a number, an
uppercase or lowercase character or none of them.

Using Function Procedure:

DECLARE FUNCTION CHTR$(A$)

CLS

INPUT “ENTER A STRING” ; C$

PRINT CHTR$(C$)

END

FUNCTION CHTR$(A$)

D$=LEFT$(A$)

A=ASC(D$)

IF A>=65 AND A<=90 THEN

CHTR$=”FIRST LETTERIS UPPERCASE LETTER”

ELSEIF A>=97 AND A<=122 THEN

CHTR$=”FIRST LETTER IS LOWERCASE”

ELSEIF A>=48 AND A<=57 THEN

CHTR$=”FIRST LETTER IS NUMBER”

ELSE

CHTR$=”NONE OF THEM”

END FUNCTION

Using SUB Procedure:

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.


QBASIC PROGRAMS For SEE Appearing Students – SET 2 | 12

DECLARE SUB CHTR(A$)

CLS

INPUT “ENTER A STRING” ; C$

CALL CHTR(C$)

END

SUB CHTR(A$)

D$=LEFT$(A$)

A=ASC(D$)

IF A>=65 AND A<=90 THEN

PRINT “FIRST LETTER IS UPPERCASE LETTER”

ELSEIF A>=97 AND A<=122 THEN

PRINT “FIRST LETTER IS LOWERCASE”

ELSEIF A>=48 AND A<=57 THEN

PRINT “FIRST LETTER IS NUMBER”

ELSE

PRINT “NONE OF THEM”

END SUB

————————————-THANK YOU—————————————–

IF YOU HAVE ANY QUERIES COMMENT BELOW

Leave a Reply
Facebook Comments ()
Google+ Comments (0)

Copyright © Subas Paudel Log on to www.subaspaudel.com.np for more.

You might also like