Question Bank Set Answer
Question Bank Set Answer
Question Bank Set Answer
q.n. 13
1. i)
sYsTeM PrOgRaMmInG
text$="system programming"
I=1, 2, 3, 4, 5, 6, 7, 8….
SCAN$="S"
I MOD 2=0 , 1 MOD 2=0 FALSE
TEMP$=TEMP$+SCAN$=""+"s"="s"
2 MOD 2=0, 2 MOD 2=0 TRUE
TEMP$=TEMP$+SCAN$="s"+"Y"="sY"
temp$=" sYsTeM PrOgRaMmInG
"
2) I - The function min() will be executed 3 times.
(print statement ending the function name min )
ii) MINIMUM VALUES IS 10
100
200
3) N=N\10
WEND
i) The purpose of this program is to reverse the given number.
ii) The value of N is 0 after completion of loop.
hw -q. n. 4
10/6/5 Thursday
q.n. 5
APPLE
C=1
B$=MID$("APPLE", 1,1)="A"
D$=D$+"A"=""+"A"=A
B$="P"
D$=D$+"P"="AP"
6)
i) only one parameter is used i.e. X -Formal parameter.
ii) In the above program, S=S+I is repeated five times.
7)
i) N$ and M$ are the string variables.
C and B are the numeric variables.
ii) Loop continues ( because the value of C will not be increased )
8)
i) N! -Formal Parameter
N -Actual Parameter
ii) Sum::9
(5+3+1)
n=int(n/10)=int (135/10)=int(13.5)=13
9)
ii)
x, y, z -Actual parameter
A, R,N-Formal parmeter
i)
3
6
12
24
ROUGH
x=3, y=2, z=4
a=x=3
r=y=2
n=z=4
I=1 TO N=1, 2, 3, 4
A=3
A=A*R=3*2=6
A=A*R=6*2=12
10/7 FRIDAY
Q.N. 11 -OUTPUT
1.
5
55
555
5555
55555
C=1
N=5
WHILE C<=5, 1<=5 TRUE
5
N=N*10+5=5*10+5=50+5=55
C=2
2<=5 TRUE
2.
OUTPUT:
25
Rough
N=1 TO 9 STEP 2=1, 3, 5, 7, 9
S=S+N=0+1=1
S=S+N=1+3=4
S=S+N=4+5=9
S=S+N=9+7=16
S=S+N=16+9=25
FIND=S
=25
PRINT FIND
3)
Total value is 639
st$="COMPUTER"
C=1
DO WHILE C<=LEN(ST$) , 1<=8 TRUE
AC=ASC(MID$(ST$, C,1))=ASC(MID$(ST$, 1, 1))=ASC("C")
=67
S=S+AC=0+65=65
C=C+1=1+1=2
2<8 TRUE
AC=ASC(MID$(ST$, 2,1))=ASC("O")=79
S=S+AC=65+97=162
M-77
P -80
U -85
T -84
E -69
R -82
S=162+77+80+85+84+69+82=638
COUNT=S=639
TOT=COUNT=639
4)
KaThMaNdU
S$="KATHMANDU"
FOR I=1 TO LEN(S$)=1, 2, 3, 4, 5, 6, 7, 8, 9
T= I MOD 2=1 MOD 2=1
IF T=1 TRUE
W$=W$+UCASE$(MID$(S$, I, 1)
W$=""+UCASE$("K")="K"
T=I MOD 2=2 MOD 2=0
IF T=1 FALSE
W$=W$+LCASE$(MID$(S$,2, 1)="K"+LCASE$("A")="K"+"a"="Ka"
HW: 6 & 7
10/9 Sunday
q.n.1
6)
THE RESULT IS 15
(Rough
z=1111 (z is actual parameter)
b=z=1111 (b is formal parameter)
b<>0 i.e. 1111<>0 true
d= b mod 10=1111 mod 10=1
e=d*2^p+e=1*2^0+0=1*1+0=1
b=int(b/10)=int(1111/10)=int(111.1)=111
p=p+1=1
111<>0 true
d=b mod 10=111 mod 10=1
e=d*2^p+e=1*2^1+1=1*2+1=2+1=3
b=int(111/10)=int(11.1)=11
p=p+1=1+1=2
11<>0 true
d=11 mod 10=1
e=d*2^p+e=1*2^2+3=1*4+3=7
b=int(11/10)=int(1.1)=1
p=p+1=2+1=3
1<>0 true
d=1 mod 10=1
e=d*2^3+e=1*2^3+7=1*8+7=15
q.n. 8
1234321
12321
121
1
m=16
p#=1111
t=1
i=20 to m=20 to 16 step -1=20, 19, 18, 17, 16
p#^2=1111^2=
p#=p#\10=1111\10=111.1=111^2
t=t+1=1=2
p#=11^2
t=3
p#=1^2
t=4
9.
NEPAL
x=78
b=x=78
print chr$(78)="N"
b=69
print chr$(69)="E"
b=80 print chr$(8)="P"
b=65
b=76
65 -A
66-B
97=a
98=b
b -Formal parameter
x-actual parameter
nepal is called procedure name
five time sub procedure NEPAL is executed.
10/10 mONDAY
oUTPUT
NO. 10
OUTPUT:
6
A=2
2 MOD 4=0 FALSE
3 MOD 4=0 FASLE
4 MOD 4=0 TRUE
S=S+A=0+4=4
8 MOD 4=0 TRUE
S=S+A=4+8=12
12 MOD 4=0 TRUE
S=S+A=12+12=24
16 MOD 4=0 TRUE
S=S+A=24+16=40
20 MOD 4=0 TRUE
S=S+A=40+20=60
Debug
q.n.
1.
REM TO COUNT THE NUMBER OF CHARACTERS
DECLARE FUNCTION char(a$)
cls
INPUT "Enter any string";a$
ch=char(a$)
PRINT "Total number of Characters is ";ch
end
function char(a$)
for x=1 to len(a$)
c=c+1
next x
char=c
end function
2.
rem to coun total passed students
cls
open "I", #1, "marks.dat"
while not eof (1)
input #1, id, m1, m2, m3
if m1>=32 and m2>=32 and m3>=32 then
x=x+1
end if
wend
print "total records";x
close #1
end
3.
REM SUM OF EVEN DIGITS
DELCARE FUNCTION RESULT(N)
CLS
INPUT "ENTER ANY NUMBER";NUM
PRINT RESULT (NUM)
END
FUNCTION RESULT(N)
DO UNTIL N=0
R =N MOD 10
IF R MOD2=0 THEN
S=S+R
END IF
N=N\10
LOOP
RESULT=S
END FUNCTION
10/11 tuesday
4.
rem searching record from a sequential file
OPEN "student.dat" for input as #1
CLS
INPUT "Enter name to search dat";N$
do
input #1, ns$, p$, s
if ns$=n$ then
print n$, p$,S
flag=1
exit do
loop while not eof(1)
if flag=0 then print "data not found"
close #1
end
5. rem to calculate
declare function mirror(n, sum)
cls
input "enter a positive number";A
rev=mirrror(a, s)
print "The revers value is ";rev
print "sum of digits";s
end
function mirror(n, sum)
m=n
do
r=m mod 10
re=re*10+r
m=int(m/10)
loop while m<>0
mirror=re
6) same as 2
7)
rem
open "src.inf" for input as #1
open "dest.inf" for output as #2
cls
while not eof(1)
input #1, nm$, rn, age
write #2, nm$, rn, age
wend
close #1, #2
end
8)
REM
OPEN "STD.DOC" FOR OUTPUT AS #1
INPUT "ENTER NAME";N$
INPUT "ENTER AGE";A
WRITE #1, N$, A
CLOSE #1
9)
DECLARE SUB GREAT(A, B, C)
GREAT A, B, C
END
SUB GREAT(A, B,C)
IF A>B AND A>C THEN
G=A
ELSEIF B>A AND B>C THEN
G=B
ELSE
G=C
END IF
PRINT G; "THE GREAT NUMBER"
END SUB
10/12 No electricity
10/13 Thursday
Debug
Set.
10.
REM TO FIND SEQUR ROOT OF GIVEN NUMBER
DECLARE SUB SQUARE(N)
INPUT N
CALL SQUARE(N)
END
SUB SQUARE(N)
S=N^-.5
PRINT S
END SUB
Q.N. 14
1 A)
DECLARE FUNCTION VOL(L,B,H, A)
REM TO FIND VOLUME AND SURACE AREA OF BOX
CLS
INPUT "Enter the length";L
INPUT "Enter the length";B
INPUT "Enter the length";H
PRINT "VOLUME OF A BOX=";VOL(L,B,H,A)
PRINT "SURFACE AREA OF BOX=";A
END
FUNCTION VOL(L,B,H,A)
VOL=L*B*H
A=2*(L*B+B*H+H*L)
END FUNCTION