Monday 17 December 2018

Qbasic Problem with Output


Qbasic Problem with Output





1.      [SLC 2065 S]

DECLARE FUNCTION Interest (p,t,r)

CLS

LET p = 30

LET t = 40

LET r = 6

LET d = Interest (p, t, r)

PRINT “The simple interest will be”; d

END

FUNCTION Interest (p, t, r)

answer= (p*t*r) /100

Interest=answer

END FUNCTION



Output:

The simple interest will be 72



2.      [SLC 2072]

DECLARE FUNCTION Interest (p,t,r)

CLS

LET p = 100

LET t = 2

LET r = 5

LET d = Interest (p, t, r)

PRINT "The simple interest =" ; d

END

FUNCTION Interest (p, t, r)

ans= (p*t*r) /100

Interest=ans

END FUNCTION



Output:

The simple interest = 10



3.      [SLC 2064]

DECLARE FUNCTION AREA (A,B)

CLS

LET A = 30

LET B = 40

LET D = AREA(A,B)

PRINT D

END

FUNCTION AREA(A,B)

PRINT A, B

AREA=A*B

END FUNCTION



Output:

30              40

1200







4.      [SLC 2068 S] [SLC 2070] [SLC 2073]

DECLARE FUNCTION AREA(L, B)

LET L = 10

LET B = 5

PRINT “The area=”; AREA(L, B)

END

FUNCTION AREA(L, B)

A = L*B

AREA = A

END FUNCTION



Output:

The area= 50



5.      [SLC 2071]

DECLARE FUNCTION AVGE(A, B, C)

X=10

Y=5

Z=15

AV= AVGE(X, Y, Z)

RPINT “Average of three numbers”; AV

END



FUNCTION AVGE(A, B, C)

S=A+B+C

AVGE = S/3

END FUNCTION



Output:

Average of three numbers 10



6.      [SLC 2067 S]

DECLARE   FUNCTION   Area (L,B)

LET   L = 100

LET   B = 20

LET   ans = Area (L,B)

PRINT  “The area is”; ans

END



FUNTION   Area (L, B)

ar = L * B

Area = ar

END FUNCTION



Output:

The area is 2000





7.      DECLARE FUNCTION AREA(L, B)

CLS

LET length = 50

LET breadth = 60

PRINT AREA (length, breadth)

PRINT AREA (10, 20)

END



FUNCTION AREA (L, B)

AREA = L * B

END FUNCTION



Output:

3000

200



8.      DECLARE SUB PAT (A)

A= -144

CALL PAT (A)

END



SUB PAT(A)

B=ABS(A)

C= SQR(B)

D=C MOD 2

PRINT A, B, C, D

END SUB



Output:

-144           144                   12                    0



9.      DECLARE SUB SHOW (S)

CLS

CALL SHOW (534)

END



SUB SHOW (N)

A = N MOD 10

B = N \ 10

C = B MOD 10

D = INT (N / 100)

PRINT “Ans=”; A + C + D

END SUB



Output:

Ans=12



10.   DECLARE SUB VOL (L, B, H)

CLS

LET L1 = 20

LET B1 = 14

LET H1 = 2

CALL VOL(L1, B1, H1)

END

SUB VOL (L, B, H)

LET V = L * B * H

PRINT “Volume=”; V

END SUB



Output:

Volume=560



11.   DECLARE SUB TEST(NUM)
CLS
CALL TEST(-5)
CALL TEST(5)
CALL TEST(0)
END

SUB TEST(NUM)
SELECT CASE NUM
CASE IS < 0
M$ = “Negative”
CASE IS > 0
M$ = “Positive”
CASE ELSE
M$ = “Zero”
END SELECT
PRINT NUM; ”is”; M$
END SUB



Output:

-5 is Negative

 5 is Positive

 0 is Zero



12.   DECLARE SUB SERIES ( )

CLS

CALL SERIES

END



SUB SERIES ( )

A = 1

B = 1

PRINT A; B;

X:

LET C = A + B

PRINT C

LET A = B

LET B = C

IF C <= 8 THEN GOTO X

END



Output:

1  1  2

3

5

8

13



13.   DECLARE SUB MIN(A, B)

CLS

A = 5

B = 10

CALL MIN(A, B)

END

SUB MIN(A, B)

IF A < B THEN

C = A + 5

PRINT C

ELSE

PRINT B ^ 2

END IF

END SUB



Output:

10



14.   DECLARE SUB OUTPOOT(L, B)

CLS

LET L = 15

LET B = 10

CALL OUTPOOT(L, B)

CALL OUTPOOT(3, 6)

END

SUB OUTPOOT(L, B)

IF L < B THEN

PRINT L

ELSE

PRINT B

END IF

END SUB



Output:

10

3



15.   DECLARE SUB FEBON(P, Q)

CLS

R = 2 : S = 1

CALL FEBON(R, S)

END



SUB FEBON(P, Q)

T = 1

PRINT P; Q;

LAB:

LET U = P + Q

PRINT U;

P = Q

Q = U

T = T + 1

IF T <=8 THEN GOTO LAB

END SUB

Output:

2  1  3  4  7  11  18  29  47  76



16.   DECLARE FUNCTION OUT(A, B)

CLS

D = OUT(17, 7)

PRINT D

END

FUNCTION OUT(A, B)

R = A MOD B

IF R MOD 2 = 0 THEN

C = R MOD 6 + 30

ELSE

C = R MOD 6 + 15

END IF

D = C \ 5

OUT = D

END FUNCTION



Output:

3







17.   DECLARE FUNCTION ABC(A, B, C)

CLS

X = 10

Y = 20

Z = 30

G = ABC(X, Y, Z)

PRINT G

END

FUNCTION ABC(A, B, C)

IF A>B AND A<C OR A<B AND A>C THEN

GG = A

ELSEIF B>A AND B<C OR B<A AND B>C THEN

GG = B

ELSE

GG = C

END IF

ABC = GG

END FUNCTION



Output:

20



18.   DECLARE FUNCTION amt(q, r)

CLS

READ q, r

DATA 5000, 10

PRINT “Amount=”; amt(q, r)

END

FUNCTION amt(q, r)

IF (q > 1000) THEN dis = 10

total = (q* r) – (q* r *dis / 100)

amt = total

END FUNCTION



Output:

Amount=45000



19.   DECLARE SUB Result()

CLS

CALL Result

END

SUB Result

A=1

FOR I = 1 TO 5

PRINT I*A

A=A+(10^I)

NEXT I

END SUB



Output:

1

22

333

4444

55555





20.   DECLARE SUB SHOW ()

CLS

CALL SHOW

END

SUB SHOW

X=30

Y=10

FOR C= 1 TO 2

PRINT X; Y;

X=X\Y

Y=X-Y

NEXT C

END SUB



Output:

3   10   3   -7



21.   DECLARE SUB Show ( )

CLS

CALL Show

END

SUB Show

C=3

B=2

FOR I=2 TO 8 STEP 2

PRINT C,

SWAP B, C

B=C+1

NEXT I

END SUB



Output:

3       2       3          4



22.   DECLARE SUB SERI ( )
CLS
CALL SERI
END
SUB SERI ( )
N=1
FOR I=1 TO 10
PRINT N;
N=N+2
NEXT I
END SUB



Output:

1   3   5   7   9   11   13   15   17   19





23.   [SLC 2066]

DECLARE SUB Series()
CALL Series
END
SUB Series
X=1
Y=1
FOR Z=1 TO 4
PRINT X;
Y=Y+1
X=X*10+Y
NEXT Z
END SUB



Output:

1   12   123   1234



24.   [SLC 2068] [SLC 2069S]

DECLARE SUB Series( )
CALL Series
END

SUB Series
A=2
B=2
For ctr=1 to 2
PRINT A; B;
A= A+B
B=A+B
Next ctr
END SUB



Output:

2   2   4   6



25.   [SLC 2066 S]

DECLARE SUB Result ( )
CALL Result
END



SUB Result
For I = 1 to 9 STEP 2
Sum=Sum +I^2
Next I
PRINT Sum
END SUB


Output:

165







26.   [SLC 2070 S]

DECLARE SUB Series ()

CALL Series

END

SUB Series

X = 0

FOR K = 10 TO 4 STEP -2

A = K ^2

X = X + A

NEXT K

PRINT X

END SUB



Output:

216



27.   DECLARE SUB SERIES()

CLS

CALL SERIES

END



SUB SERIES( )

X#=11111

FOR I= 1 TO 5

PRINT X#^2

X# = (X# - 1) / 10

NEXT I

END SUB



Output:

123454321

1234321

12321

121

1



28.   [SLC 2069]

DELARE SUB NUMBER()

CLS

CALL NUMBER

END

SUB NUMBER

N=3

C=1

WHILE C<=5

      PRINT N

      N=N*10+3

      C=C+1

WEND

END SUB



Output:

3

33

333

3333

33333

29.   DECLARE SUB SER ( )

CALL SER

END



SUB SER

A=1

B=1

FOR I=1 TO 10 STEP 2

PRINT A*B

A=A*10 + 1

B=B+1

NEXT I

END SUB



Output:

1

22

333

4444

55555



30.   DECLARE SUB num ( )

CLS

CALL num

END



SUB num

F = 2

S = 1

FOR K = 5 TO 1 STEP -1

A = A + S

PRINT A

S = S + F

NEXT K

END SUB



Output:

4

9

9

16

25





31.   DECLARE SUB skill( )

CLS

CALL skill

END



SUB skill

LET N=5

LET A=4

FOR  J = 1 TO 5 STEP 1

PRINT N

N=N*10+A

A=A+1

NEXT  J

END SUB



Output:

5

54

545

5456

54567



32.   DECLARE SUB RESULT ( )

CLS

CALL RESULT

END



SUB RESULT ( )

Z = 3

FOR A = 1 TO 10

PRINT (A^2)*Z

NEXT A

END SUB



Output:

3

12

21

48



33.   DECLARE SUB SHOW( )

CLS

CALL SHOW

END

SUB SHOW ( )

A = 15

FOR I = 1 TO 4

PRINT A MOD I + 2

SUM = SUM + A \ 10

A = A – 1

NEXT I

PRINT SUM

END SUB

Output:

2

2

3

2

4



34.   DECLARE SUB SERI()

CLS

CALL SERI

END

SUB SERI()

FOR I= 1 TO 4

FOR J=1 TO I

PRINT (I+J)*10;

NEXT J

PRINT

NEXT I

END SUB



Output:

20

30   40

40   50   60

50   60   70   80



35.   DECLARE SUB CHECK ()

CALL CHECK

END

SUB CHECK

CLS

FOR K = 1 TO 5

FOR I = 5 TO K STEP -1

PRINT I;

NEXT I

PRINT

NEXT K

END SUB



Output:

54321

5432

543

54

5

















36.   DECLARE SUB FIND(N)

CLS

N=654

CALL FIND(N)

END

SUB FIND(N)

WHILE N < > 0

R= N MOD10

P= P*10 + R

N= N \ 10

WEND

PRINT P

END SUB



Output:

456



37.   DECLARE SUB SERIES()

CALL SERIES

END

SUB SERIES()

R=2

M=5

WHILE M>=1

PRINT R

R=R*10+2

M=M-1

WEND

END SUB



Output:

2

22

222

2222

22222



38.   DECLARE SUB SERU ()

CALL SERU

END

SUB SERU ()

X =2

C =1

WHILE C <=10

S =X^C

PRINT S
C =C+1

WEND

END SUB

Output:

2

4

8

39.   DECLARE SUB PER(P)

P=15

CALL SER(12)

END

SUB SERIES (P)

M=3

WHILE M<7

PR=M*P

PRINT PR,

M=M+2

WEND

END SUB



Output:

36              60



40.   CLS

X=0

Y=0

C=1

WHILE C<=10

CALL Variance ((X), Y)

C=C+1

WEND

END



SUB Variance (A,B)

A=A+10

B=B+10

PRINT A, B

END SUB



Output:

10              10

10              20

10              30

10              40

10              50

10              60

10              70

10              80

10              90

10              100



41.   DECLARE SUB RESULT()

CALL RESULT

END

SUB RESULT

N=7

C=5

DO UNTIL C=1

PRINT N

N=N*10+7

C=C-1

LOOP

END SUB

Output:

7

77

777

7777



42.      DECLARE  FUNCTION  TEST (N)

CLS

FOR  J= 3 TO 9 STEP 2

X= TEST(J)

PRINT X

NEXT J

END



FUNCTION TEST (N)

TEST = (N^2)+ 2

END FUNCTION

Output:

11

27

51

83



43.   DECLARE FUNCTION PATTERN (N)

B=4

PRINT PATTERN (B)

END

FUNCTION PATTERN (K)

FOR M = 1 TO K

T=T+2

D=D+T

NEXT M

PATTERN = D

END FUNCTION



Output:

20



44.   DECLARE FUNCTION CONVERSION(B)

CLS

Z=1111

ANS= CONVERSION(Z)

PRINT”THE RESULT”;ANS

END

FUNCTION CONVERSION(B)

P=0

DO WHILE B<>0

D= B MOD 10

E = D*2^P+E

B = INT(B/10)

P = P+1

LOOP

CONVERSION=E

END FUNCTION

Output:

THE RESULT 15

45.   DECLARE FUNCTION A(X)

X=10

Z=A(X)

PRINT Z

END



FUNCTION A(X)

FOR I= 1 TO X STEP 2

S=S+I

NEXT I

A=S

END FUNCTION



Output:

25



46.   DECLARE FUNCTION TEST (A, B)

CLS

X=2: Y=8

PRINT “THE RESULT IS”; TEST(X,Y)

END

FUNCTION TEST (A, B)

FOR J = A to B STEP 2

P=P+J

NEXT J

TEST = P

END FUNCTION



Output:

THE RESULT IS 20

47.   DECLARE FUNCTION XYZ (N)

S = 0

FOR K = 1 TO 4

READ XY

S = S + XYZ (XY)

NEXT K

PRINT S

DATA 5, 4, 3, 2

END

FUNCTION XYZ (N)

XYZ = (N ^ 2)\2

END FUNCTION



Output:

26



48.   DECLARE SUB PATT(A$)

CLS

A$ = “*”

CALL PATT(A$)

END

SUB PATT(A$)

A = 10

FOR I = 1 TO 11 STEP 2

PRINT TAB(A); STRING$(I,A$)

A = A-1

NEXT

END  SUB

Output:

     *  

    ***

  *****

 *******

*********



49.   DECLARE SUB OUTP(A$)

CLS
A$ = “COMPUTER”

CALL OUTP(A$)

END

SUB OUTP(A$)

B = LEN(A$)

C = 1

LAB:

PRINT LEFT$(A$, C)

C = C + 1

IF C <= B THEN GOTO LAB

END SUB



Output:

C

CO

COM

COMP

COMPU

COMPUT

COMPUTE

COMPUTER





50.   DECLARE SUB CHK (N$())

CLS

FOR I= 1 TO 6

READ N$(I)

NEXT I

CALL CHK (N$())

DATA Patan, Pray, Ada, Cabbage, English, Samsung

END

SUB CHK (N$())

FOR I = 1 TO 6

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

NEXT I

PRINT S$

END SUB



Output:

Prabin



51.   DECLARE SUB DISPLAY(B$)

CLS

CALL DISPLAY(“101”)

END



SUB DISPLAY(B$)

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

A$=MID$(B$,I,1)

C=VAL(A$)

D=D+C*8^P

P=P+1

NEXT I

PRINT D

END SUB



Output:

65



52.   DECLARE SUB RESULT (S$)

CLS

A$=”PROGRAMMER”

CALL RESULT (A$)

END

SUB RESULT (A$)

FOR C= LEN (A$) TO 1 STEP -2

X$= MID$(A$, C, 1)

PRINT X$;

NEXT C

END SUB



Output:

RMAGR



53.   DECLARE SUB PRO (A AS INTEGER, B AS STRING)

CLS

N = 62

CALL PRO (N, S$)

PRINT S$

END

SUB PRO (A AS INTEGER, B AS STRING)

X = A

DO

R = X MOD 8

B = STR$ (R) + B

X = (X - R) / 8

LOOP UNTIL X = 0

END SUB



Output:

76



54.   DECLARE SUB SHOW (ABC$)

CLS

AB$="ZHTUOMENXSA"

CALL SHOW (AB$)

END



SUB SHOW (AB$)

Y=48

FOR I=1 TO 5

N=Y MOD 7

PRINT MID$(AB$, N, 1);

Y=Y-1

NEXT I

END SUB



Output:

MOUTH



55.   DECLARE SUB RESULT ( )
CLS
CALL RESULT
END

SUB RESULT ()

W$="SCIENCE"

L=LEN (W$)

X=1: Y=3

FOR I= 1 TO L STEP 2

PRINT TAB (Y); MID$(W$, X, L)

X=X+1

L=L-2

Y=Y+1

NEXT I

END SUB



Output:

SCIENCE
   CIENC

      IEN

        E



56.   [SLC 2065]

DECLARE SUB RESULT(A$)

A$ = "education"
CALL RESULT(A$)
END

SUB RESULT (A$)
FOR C = 1 TO LEN(A$) STEP 2
 X$ = MID$(A$, C, 1)
PRINT X$
NEXT C
END SUB



Output:

e

u

a

i

n





57.   [SLC 2067]

DECLARE SUB RESULT(N$)

N$ = "SCIENCE"
CALL RESULT(N$)
END


SUB RESULT (N$)
B = LEN(N$)
COUNT = 1
WHILE COUNT <= B
 X$ = X$ + MID$(N$, COUNT, 1)
 COUNT = COUNT + 2
WEND
PRINT X$
END SUB



Output:

SINE



58.   [SLC 2074]

DECLARE SUB Display (T$)

CLS

T$ = "COMPUTER"

CALL Display (T$)

END

SUB Display (T$)

FOR C = 1 TO LEN (T$) STEP 2

D$ = MID$ (T$, C, 1)

PRINT D$;

NEXT C

END SUB



Output:

CMUE



59.   DECLARE SUB TEST(A$)

CLS

A$="NEPAL"

CALL TEST(A$)

END



SUB TEST(A$)

FOR I = 1 TO LEN(A$)

B$ = MID$(A$, I, 1)  +  B$

NEXT I

PRINT B$

END SUB



Output:

LAPEN





60.   DECLARE SUB FIRST()

CLS

CALL FIRST

END



SUB FIRST()

A$=”BHAKTAPUR”

FOR I=1 TO LEN(A$)

B$ = MID$(A$,I,1)

PRINT B$

NEXT I

END SUB



Output:

 B

H

A

K

T

A

P

U

R         



61.   DECLARE  SUB  PICTURE (ST$)

CLS

X$ = "SCIENCE"

CALL PICTURE(ST$)

END



SUB PICTURE(S$)

T=20

P=4

N=1

FOR A= 1 TO 4

PRINT TAB(T); MID$(ST$,P,N)

P=P-1

N=N+2

T=T-1

NEXT A

END SUB



Output:

      E

     IEN

  CIENC

SCIENCE



62.   DECLARE SUB EVE (BA$)

CLS

CALL EVE("CHOYU")

END





SUB EVE(BA$)

COL=1

FOR I= LEN(BA$) TO 1 STEP -2

PRINT TAB(COL);MID$(BA$,COL,I)

COL=COL+1

NEXT

END SUB

Output:

CHOYU

   HOY

      O



63.   DECLARE SUB PATTERN (W$)

CLS

LET W$=”KATHMANDU”

CALL PATTERN (W$)

END



SUB PATTERN (W$)

T=5

FOR K=1 TO LEN(W$) STEP 2 

PRINT TAB(T); MID$(W$,T,K)

T=T-1

NEXT K

END SUB



Output:

           M

         HMA

      THMAN

   ATHMAND

KATHMANDU

64.   DECLARE SUB TEST(N$)

CLS    

A$ = “KATHMANDU”                                                                              

CALL TEST(A$)

CALL TEST(“BHAKTAPUR”)

END



SUB TEST(N$)

FOR C = 1 TO LEN(N$)

PRINT LEFT$ (N$,C)

NEXT C

END SUB

Output:

K

KA

KAT

KATH

KATHM

KATHMA

KATHMAN

KATHMAND

KATHMANDU

B

BH

BHA

BHAK

BHAKT

BHAKTA

BHAKTAP

BHAKTAPU

BHALTAPUR

65.   DECLARE SUB PATTERN(S$)

CLS

B$=”PROGRAM”

CALL PATTERN(B$)

END



SUB PATTERN(S$)

H=LEN(S$)

I=10

FOR J=1 TO H STEP 2

PRINT TAB(I); MID$(S$,J,H)

H=H-2

I=I+1

NEXT J

END SUB



Output:

PROGRAM

  ROGRA

     OGR

        G



66.   DECLARE FUNCTION OUTP$(A$())

DIM A$(5)

FOR I=1  TO 5

READ A$(I)

NEXT I

DATA NETRA, NAVIN, SUSAN, GOPAL, SUNIL

PRINT OUTP$(A$())

END

FUNCTION OUTP$(A$())

SWAP A$(1),A$(2)

SWAP A$(3),A$(4)

FOR J=1 TO 5

T$=T$+MID$(A$(J),J,1)

NEXT J

OUTP$=T$

END FUNCTION



Output:

NEPAL



67.   DECLARE FUNCTION RE$(ST$())

DIM ST$(7)

CLS

FOR I=1 TO 7

INPUT "Enter string"; ST$(I)

NEXT I

PRINT "The reverse string is :"; RE$(ST$())

DATA “Prabhu”, “Alok”, “Bimal”, “Suman”, “Ishwor”, “Om”, “Nitu”

END



FUNCTION RE$(ST$()))

FOR J = 1 TO 7

VR$ = VR$ + MID$(ST$(J), I,1)

NEXT J

RE$=VR$

END FUNCTION



Output:

PABSION



68.   DECLARE FUNCTION OUT$(A$( ))

DIM A$(6)

FOR A = 0 to 5

READ A$(A)

NEXT A

DATA SARITA, JEHEN, RADHIKA, ISHIKA, DILIP, BRIJESH

PRINT OUT$(A$( ))

END

FUNCTION OUT$(A$( ))

CTR = 1

FOR R = 0 TO 5

T$ = T$ + MID$ (A$(R), CTR, 1)

CTR = CTR + 1

NEXT R

OUT$ = T$

END FUNCTION

Output:

SEDIPS



69.   DECLARE FUNCTION answer$(x$)

CLS

Y$ = “Question”

PRINT answer$(Y$)

END

FUNCTION answer$(x$)

FOR I = LEN(x$) to 1 STEP – 4

Z$ = MID$(x$, I, 1) + Z$

NEXT i

answer$ = Z$

END FUNCTION



Output:

Sn



70.   DECLARE FUNCTION FIND (M, N)

READ X, Y

PRINT FIND (X, Y)

PRINT FIND (5, 10)

DATA 14, 8

END   



FUNCTION FIND (A, B)

IF A>B THEN SWAP A, B

Q= 0

FOR I = A TO B

IF I MOD 2=1 THEN Q=Q+1

NEXT I

FIND=Q

END FUNCTION



Output:

3

3



71.   DECLARE FUNCTION ABC(X)

CLS

FOR I=1 TO 8

READ N

Z=ABC(N)

S=S+Z

NEXT I

PRINT S

DATA 7, 22, 11, 34, 17, 52, 26, 13

END

FUNCTION ABC(X)

IF X MOD 2 < > 0 THEN ABC=X

END FUNCTION



Output:

48



72.   DECLARE FUNCTION ABC (N)

S = 0

FOR K=1 TO 6

V= ABC (K)          

PRINT  V

S = S + V

NEXT K

PRINT S

END



FUNCTION ABC (N)

IF N MOD 2 = 0 THEN

ABC = N*N

ELSE

ABC = 0

END IF

END FUNCTION



Output:

0

4

0

16

0

36

56





73.   DECLARE FUNCTION CHECK(A)

CLS

PRINT CHECK(4387)

END



FUNCTION CHECK(A)

WHILE A<>0

R=A  MOD 10

IF R MOD 2=0 THEN

S=S+R

END IF

A=A\10

WEND

CHECK=S

END FUNTION



Output:

12



74.   DECLARE FUNCTION CHECK (B)

A = 125

S = 0

CLS

PRINT “OUTPUT:::”;CHECK (A)

END



FUNCTION CHECK (B)

WHILE B<>0

C = B MOD 10

IF C MOD 2=1 THEN D = D + C^3

B = INT(B/10)

WEND

CHECK = D

END FUNCTION



Output:

OUTPUT::: 126



75.   DECLARE SUB NUM( )

CLS

CALL NUM

END

SUB NUM()

A = 3

FOR I = 1 TO 10

PRINT A,

IF A MOD 2 < > 0 THEN

A = A*3+1

ELSE

A =A/2

ENDIF

NEXT I

END SUB

Output:

3         10        5          16        8

4          2           1           4           2

76.   DECLARE SUB RESULT(X,Y)

CALL RESULT(3,9)
END



SUB RESULT(X,Y)

FOR I = X TO Y

R=I MOD 2

IF R=1 THEN PRINT I

NEXT I
END SUB



Output:

3

5

7

9



77.   DECLARE SUB RSLT (A, B)

CALL RSLT (3, 15)

END



SUB RSLT (A, B)

FOR I = A TO B

R = I MOD 2

IF R = 0 THEN PRINT I

NEXT

END SUB



Output:

4

6

8

10

12

14



78.   DECLARE SUB DISPLAY(X)

CLS

FOR N = 1 TO 10 STEP 3

CALL DISPLAY (N)

NEXT N

END



SUB DISPLAY (X)

IF X MOD 2 =1 THEN PRINT X;

END SUB



Output:

1   7





79.   DECLARE SUB G(A, B)

CLS

FOR X = 1 TO 4

READ P, Q

CALL G(P, Q)

NEXT X

DATA 4, 5, 8, 6, 15, 10, 17, 19

END

SUB G(A, B)

IF A < B THEN

TH = A

ELSE

TH = B

END IF

PRINT TH

END SUB



Output:

4

6

10

17



80.   DECLARE SUB ABC(A)

CLS

FOR I = 1 TO 5

READ N

CALL ABC(N)

NEXT I

DATA 24, 15, 48, 18, 12

END



SUB ABC(N)

R = N MOD 4

R1 = N MOD 6

IF R = 0 AND R1 = 0 THEN

PRINT N

END IF

END SUB



Output:

24

48

12



81.   DECLARE SUB OUTPOOT()
CLS
CALL OUTPOOT
END



SUB OUTPOOT
I=1
N=10
DO
IF N MOD 2=0 THEN PRINT N
I=I+1
N=N+1
LOOP UNTIL I>9
END SUB



Output:

10

12

14

16

18





82.   DECLARE SUB TEST(A$)

CLS

A$ = “COMPUTER”

CALL TEST(A$)

END



SUB TEST(A$)

FOR I=1 TO LEN(A$)

B$=MID$(A$,I,1)

C=ASC(B$)

IF C MOD 2 =0 THEN

D$=D$+CHR$(C+32)

ELSE        

D$=D$+B$

ENDIF

NEXT I

PRINT D$

END SUB



Output:

COMpUtEr



83.   DECLARE SUB DISPLAY(S$)

CLS

A$=”MAAF”

DISPLAY A$

END



SUB DISPLAY(S$)

L=LEN(S$)

FOR I=L TO 1 STEP -1

VER$=MID$(S$, I, 1)

IF I MOD 2 =1 THEN

CON$=CON$+LCASE$(VER$)

ELSE

CON$=CON$+UCASE$(VER$)

END IF

NEXT

PRINT CON$

END SUB



Output:

FaAm



84.  DECLARE SUB ABC (N$)

N$=”KATHMANDU”

CALL ABC (N$)

END



SUB ABC (N$)

CLS

FOR J= 1 TO LEN (N$)

C$=MID$(N$, J, 1)

SELECT CASE C$

CASE “A”,”E”,”I”,”O”,”U”

X$=C$+X$

CASE ELSE

Z$=C$+Z$

END SELECT

NEXT J

PRINT Z$

END SUB



Output:

DNMHTK



85.   DECLARE FUNCTION outp$(S$)

S$ = “KATHMANDU”

PRINT outp$(S$)

END

FUNCTION outp$(S$)

FOR I = 1 to LEN(S$)

t = I MOD 2

IF t = 1 then

W$ = W$ + UCASE$ (MID$(S$, I, 1)

ELSE

W$ = W$ + LCASE$ (MID$(S$, I, 1)

END IF

NEXT I

outp$ = W$

END FUNCTION



Output:

KaThMaNdU



86.   DECLARE FUNCTION TEST$(A$)

CLS

A$="computer"

PRINT TEST$(A$)

END

FUNCTION TEST$(A$)

FOR K=1 TO LEN(A$)

B$=MID$(A$,K,1)

IF B$="a" OR B$="e" OR B$="i" OR B$="o" OR B$="u" THEN

C$=C$+UCASE$(B$)

ELSE

C$=C$+B$

END IF

NEXT K

TEST$ = C$

END FUNCTION



Output:

cOmpUtEr









87.   DECLARE FUNCTION CONV$(D)

CLS

D = 509

PRINT CONV$(D)

END

FUNCTION CONV$(D)

WHILE D<>0

R = D MOD 16

IF R < 10 THEN

S$ = STR$(R) +S$

ELSE

S$ = CHR$(R+55) +S$

END IF

D = D\16

WEND

CONV$ = S$

END FUNCTION



Output:

1FD







88.   DECLARE FUNCTION VCOUNT(A$)
X$=”SCHOOL”
Y$=” INSTITUTE”
IF VCOUNT(S$)>VCOUNT(Y$) THEN PRINT X$ ELSE PRINT Y$
END


FUNCTION VCOUNT(A$)
N$=UCASE$(A$)
FOR X= 1 TO LEN(N$)
C$=MID$(N$,I,1)

IF C$=”A” OR C$=”E” OR C$=”I” OR C$=”O” OR C$=”U” THEN V=V+1
END IF
NEXT X
VCOUNT=V
END FUNCTION



Output:

INSTITUTE



89.   DECLARE FUNCTION PAB(S$)

CLS

R$=”Today is my computer exam”

PRINT PAB(R$)

END



FUNCTION PAB(S$)

C=1

FOR I = 1 TO LEN(S$)

A$=MID$(S$,I,1)

IF A$= “m” THEN C=C+1

NEXT I

PAB=C

END FUNCTION



Output:

3



90.   DECLARE FUNCTION CNT(ST$)

CLS

ST$ = “COMPUTER”

TOT = CNT(ST$)

PRINT TOT

END



FUNCTION CNT(ST$)

C = 1

DO WHILE C <= LEN(ST$)

A = ASC(MID$(ST$, C, 1)

S = S + A

C = C + 1

LOOP

CNT = S

END FUNCTION



Output:

623


No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint