Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Friday, February 18, 2022

Analytical questions of QBASIC

Analytical questions of QBASIC for SEE and grade 10 students

Analytical questions of QBASIC for SEE and grade 10 students


Read the following program and answer the questions below. (It carries 2 Marks)

1)        Specification Grid 2077

OPEN “Detail.dat” FOR INPUT AS #1

OPEN “Temp.dat” FOR OUTPUT AS #2

INPUT “Enter name of the students “; Sn$

FOR I = 1 TO 10

INPUT #1, Nm$, Cl, A

IF Sn$ <> Nm$ THEN

WRITE #2, Nm$, Cl, A

END IF

NEXT I

CLOSE #1, #2

KILL “Detail.dat”

NAME “Temp.dat” AS “Detail.dat”

END

i) What is the main objective of the above program?

Ans: Above program is used to delete the unwanted records.

 

ii) Do you get any problem in the above program if “Kill” statement is removed? Give reason.

Ans: Yes/ If we remove KILL statement from above program we are not able to remove unwanted records because all the unwanted records are there in the file called “detail.dat” which we use KILL statement.

 

2)         SEE 2078

DECLARE FUNCTION TEST(X)

X=100

Z=TEST(X)

PRINT Z

END

 

FUNCTION TEST (X)

FOR R=1 TO X

S=S+1

NEXT R

TEXT =S

END FUNCTION

a) How many parameters are used in the above program?

Ans: one

b) How many times does the statement S=S+1execute in the above program?

Ans: 100 times

 

3)

OPEN "EMP.DAT" FOR INPUT AS#1

DO

 INPUT #1, N$, A$, S

 IF UCASE$(A$)="KATHMANDU" THEN

 PRINT N$, A$, S

 END IF

LOOP WHILE NOT EOF(1)

CLOSE #1

END

a) Write the use of statement "INPUT#1, N$,A$,S" in the above program.

Ans: This statement is used to read the data from the data file.

 

b) What happens if you remove "UCASE$" from the above program.

Ans: If we remove he statement UCASE$ from the above program the address "KATHMANDU" which are stored in capital letter are not displayed on the screen.

 

4)        

DECLARE FUNCTION test$(N$)

CLS

INPUT "Enter any string "; X$

PRINT test$(X$)

END

FUNCTION test$(N$)

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

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

NEXT I

test$=W$

END FUNCTION

(a) What is the main objective of the program given above?

Ans: The above program will display the input string in reverse order.

 

(b) List all the parameters used in above program.

Ans: Formal parameter= N$

        Actual/Real parameter is : X$

 

5)         SEE Pre-board examination 2078

DECLARE FUNCTION text$(a$)

CLS

INPUT “Enter any word”;t$

PRINT text$(t$)

END

FUNCTION text$(a$)

FOR m=LEN(a$) TO 1 STEP -1

C$=c$+MID$(a$,m,1)

NEXT m

Text$=c$

END FUNCTION

a) List the formal and actual parameter used in the program given above.

Ans:         Formal parameter=a$

                 Actual parameter=t$

b) List the library function used in above program.

     Library functions are: LEN, MID$

 

6)

OPEN "EMP.DAT" FOR INPUT AS #1

DO

INPUT #1,N$,A$,S

IF UCASE$(A$) = "DHANGADHI" THEN

PRINT N$,A$,S

END IF

LOOP WHILE NOT EOF(1)

CLOSE #1

END

a) Why the INPUT #1,N$,A$,S statement is used in above program?

Ans: This statement is used to read the data from the data file.

b) What happens if you delete “UCASE$ from the above program?

Ans: If we remoe UCASE$(A$) from above program the address "DHANFADHI" which is written in small letter is not going to disply.

 

7)

DECLARE SUB avn(t$)

CLS

INPUT “Enter string”;R$

CALL TEST (R$)

END

 SUB avn (t$)

FOR I = 1 TO LEN(A$)

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

NEXT I

PRINT b$

END SUB

a. Write the name of procedure used in the above program.

Ans: Name of procedure is: avn

b. List out all the real and formal parameters used in the above program.

Ans: Formal parameter: t$

     Real parameter: r$

 

8)         SEE Grade Promotion Exam 2078(2022)

 

DECLARE FUNCTION prod(a,b)

CLS

INPUT "Enter first number";a

INPUT "Enter second number";b

PRINT "The product of the two number=";prod(a,b)

END

 

FUNCTION prod(a,b)

p=a*b

prod=p

END FUNCTION

a) List the numerical variables used in the program.

Ans: A, B, and P are the numerical variables used in the above program.

b) List the local variables used in the above program.

Ans: P is the local variable used in the above program.

 

9.     SEE 2079 (2023)

DECLARE FUNCTION sum(n)

CLS

INPUT "Enter any number";n

x=sum(n)

PRINT "The sum of individual digit is ";x

END

 

FUNCTION sum(n)

WHILE n<>0

r= n MOD 10

s=s+r

n=INT(n/10)

WEND

sum=s

END FUNCTION

 

Questions:
i) Write the function of INT.
Ans: The function of INT is to return the integer portion of a given number.
ii) How many times does the WHILE ...WEND loop repeat if the value of n is 123?
Ans: If the value of n is 123, 3 (three) times WHILE...WEND loops will repeat.

 

 10)    Specification Grid 2065

DECLARE FUNCTION a(x)

CLS

x=5

z=a(x)

PRINT z

END

FUNCTION a(x)

FOR i= 1 to x

s=s+i

NEXT i

a=s

END FUNCTION

i)       How many parameters are used in the program?

Ans:  One.

ii)      How many times statement s=s+I executes in above program.

Ans:  5 times

 

11)    SLC 2065

DECLARE FUNCTION diff(a,b)

CLS

INPUT "Enter first number";a

INPUT "Enter second number";b

PRINT "The difference of the two number=";diff(a,b)

END

FUNCTION diff(a,b)

d=a-b

diff=d

END FUNCTION

i)       What will be the output of the program if the user inputs 200 as first number and 100 as the second number?

Ans:  The difference of the two number=100

ii)      Will the program run if the first line (i.e DECLARE …..) is deleted?

          Ans:          No.

 

12)    SLC supplementary 2065

DECLARE FUNCTION xyz(n)

FOR i=1 TO 5

READ n

z=xyz(n)

s=s+z

NEXT i

PRINT S

DATA 10, 13, 15, 4, 6

END

FUNCTION xyz(n)

IF n MOD 2=0 THEN xyz=n

END FUNCTION

i)       What is the name of function used in the above program?

Ans:  xyz

ii)      How many times function will be called in the above program?

Ans:  5 times.

13)    SLC 2066

DECLARE FUNCTION num(n)

INPUT n

s=num(n)

PRINT s

END

FUNCTION num(n)

x=INT(17/n)

y=15 MOD n

num=x+y

END FUNCTION

i)       Write the name of the function used in above program?

Ans:  num

ii)      List the mathematical function(library) used in the above program.

Ans:  INT

 

14)    SLC supplementary 2066

DECLARE FUNCTION count(a$)

INPUT "Enter a word";w$

END

FUNCTION count(a$)

b=LEN(a$)

c$=UCASE$(a$)

FOR i=1 TO b

e$=MID$(c$,I,1)

IF e$="A" OR e$="E" OR e$="I" OR e$="O" OR e$="U" THEN

c=c+1

ENDIF

NEXT i

count=c

END FUNCTION

i)       List the string library function used in the above program.

Ans:  LEN, UCASE$, MID$.

ii)      Write down the missing statement in the main module to execute the program.

Ans:  After third line of main module write PRINT count(w$)

 

15)    SLC 2067

DECLARE SUB sum(n)

INPUT "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=";s

END SUB

i)       In which condition the statement within the WHILE…..WEND looping statement will not be executed?

Ans:  If n=1.

ii)      Will the output be same if the place "\" instead of "/" in the above program?

Ans:  No.

 

16)

DECLARE SUB result (m$)

m$ = "COMPUTER"

CALL result(m$)

END

SUB result (m$)

CLS

LET c = LEN(m$)

LET b = 1

WHILE b <= c

PRINT MID$(m$, b, 1);

b = b + 2

WEND

END SUB

a)      What is the value of C in above program.?

Ans:  8

b)      How many parameters are used in above SUB procedure?

Ans:  One (1) parameter is used in above sub procedure.

c)       List out the numeric and string variable used in the above program.

Ans:  i) Numeric variable: c, b

          ii) String variable: m$

d)      What will happen if the statement b=b+2 removed from the program?

Ans:  If the statement b=b+2 will removed from the program then the loop will be terminate

 

17)

DECLARE SUB res(a$)

CLS

a$="AISHWARYA"

CALL res(a$)

END

SUB res(a$)

L=LEN(a$)

FOR x= L to 1 STEP -2

PRINT MID$(a$,x,1);

NEXT x

END Sub

a)             What will be the output of the above program?

Ans:  ARWSA

b)              List out the numeric and string variable used in program.

Ans:  i) Numeric variable= L, x ii) String variable= a$

c)             What will be the value of L if a$="DHANGADHI"

Ans:  8

d)             What will be the output if we change STEP -3 ?

Ans:  AAS

 

18)

DECLARE SUB ser (x, y)

CLS

CALL ser(4, 4)

END

SUB ser (x, y)

CLS

c = 0

FOR a = 1 TO 5

PRINT x;

c = x + y

x = y

y = c

NEXT a

END SUB

a)             Write the output of the above program.

Ans   4 4 8 12 20

b)             List the variable used in sub program.

Ans:  Variables are c,a,x,y

c)             What will be the value of variable "c" when loop completes fourth time?

Ans:  12

d)             What will be the output if sub procedure called with "CALL ser(2,3)

Ans:  2 3 5 8 13

 

19)

DECLARE SUB result(n$)

INPUT "Enter your strng:";n$

CALL result(n$)

END

SUB result (n$)

FOR x= LEN(n$) to 1 STEP -1

PRINT LEFT$(n$,x)

NEXT x

END SUB

a.             How many time loop executes if input string is "DHANGADHI"

Ans:  8 times

b.             What type of data is assigned in the variable name n$

Ans:  Text or string type of data assigned in the variable name n$

c.              What will be the output if the input string is "NEPAL"

Ans:  NEPAL

          NEPA

          NEP

          NE

          N

d.             What will be the output if we change RIGHT$(n$,x) in the place of LEFT$(n$,x), if input string is "COMPUTER".

Ans:  COMPUTER

          OMPUTER

          MPUTER

          PUTER

          UTER

          TER

          ER

          R

20)

DECLARE SUB strin(x$)

X$="COMPUTER"

END

SUB strin(x$)

L=LEN(x$)

FOR I = L to 1 STEP -2

PRINT MID$(x$,x,1)

NEXT I

END SUB

a)      What should be added in main module to execute the program

Ans:  CALL strin(x$)

b)      What will be the output of the program?

Ans:  R T P O

c)       What will be the value of L if x$="NEPAL"

Ans:  5

d)      List out numeric and string variable used in the program.

Ans:  i) Numeric variable: L and I ii) String variable: x$

 

21)    SLC 2063

DECLARE SUB word(n$)

N$="SCIENCE"

CALL word(n$)

END

SUB word(n$)

LET b=LEN(n$)

LET c=1

WHILE c<=b

M$=MID$(n$,c,1)

PRINT m$;

C=c+2

WEND

END SUB

a)      What is the value of 'b' in the above program?

Ans:  The value of 'b' is 7

b)      How many parameters are used in above SUB procedure?

Ans:  One parameter is used in above SUB procedure.

c)       List out the numeric and string variable used in the above program.

Ans:  i) Numerical variables = b and c ii) String variables are= n$,m$

d)      If the statement c=c+2 is removed in above program then find out whether the loop terminates or continues?

Ans:  If the statement c=c+2 is removed in above program then the loop terminates.

 

22)

DECLARE SUB tt (a!, b!, c!)

DECLARE SUB tta (a, b, c)

CLS

READ x, y, z

CALL tt(x, y, z)

DATA 2,6,4

END

SUB tt (a, b, c)

IF a < b THEN SWAP a, b

IF b < c THEN SWAP b, c

PRINT a, b, c

END SUB

a)      What will be the output of the above program?

Ans:  6       4        2

b)      How many arguments are passed in above progeam?

Ans:  3 arguments are passed.

 

23)

CLS

DECLARE FUNCTION cube (t, r)

n = 15

s = cube(2, 4)

PRINT "cube="; s

END

FUNCTION cube (p, m)

cube = p ^ 3

n = n - 5 * 2

END FUNCTION

a)      Find out the error in above program

Ans:  Line no 1 of the program. (Before Declare statement the CLS

 statement is used.

b)      Write the output of the program:

Ans:  8

c)       List any two mathematical operators used in this program.

Ans:  * and –

 

24)    SLC 2064

DECLARE FUNCTION cells$ (w$)

w$ = "CYBER"

PRINT cells(w$)

END

FUNCTION cells$ (w$)

k = LEN(w$)

FOR i = k TO 1 STEP -2

m$ = m$ + MID$(w$, i, 1)

NEXT i

cells$ = m$

END FUNCTION

a)      Why is $(dollar) sign followed in function name?

Ans:  The $(dollar) sign is followed in function name because the function is string type.

b)      What will be the output of the program when it is executed?

Ans:  RBC

c)       What will be the output of the program whe FOR loop is changed as FOR i= 1 to K STEP 2

Ans:  CBR

d)      What is the name of sign “+” used in the above program and what operation does it performed?

Ans:  It means string concatenation or string addition.

 

25)    SLC 2068

DECLARE FUNCTION count(n$)

INPUT “Enter a word”;r$

C=count(r$)

PRINT c

END

FUNCTION count(n$)

FOR k= 1 to LEN(n$)

X$=MID$(n$,k,1)

IF UCASE$(x$)=”A” THEN

X=x+1

ENDIF

NEXT k

Count=x

END FUNCTION

a)      List any two library functions used in the above program.

Ans:  Library Functions: LEN, MID$, UCASE$

b)      Write the use of variable ‘C’ in line 3 given in the above program.

Ans:  Variable C is used to store the returned statement by function in the above program.

 

26)    SLC 2069

Study the following program and Answer the given questions:

DECLARE SUB EXAM (N$)

CLS

INPUT “Enter word”;WO$

CALL EXAM(WO$)

END

SUB EXAM (N$)

FOR I= 1 TO LEN(N$)

PRINT RIGHT$(N$,I)

NEXT I

END SUB

a)      Write the name of two built in functions used in the above program.

Ans:  LEN, RIGHT$

b)      List the real parameter in the program.

Ans:  WO$

 

27)    SLC 2070

DECLARE FUNCTION sum(a,b)

INPUT “Enter first number”;a

INPUT “Enter second number”;b

PRINT “The sum of the two numbers=”;sum(a,b)

END

FUNCTION sum(a,b)

S=a+b

Sum=s

END FUNCTION

a.       List the numerical variables used in the above program?

Ans:  A,B,S

b.       Will the program run if the first line (i.e DECLARE……) is deleted?

Ans:  Yes, the program will execute, even if the declare line is deleted.

 

28)    SLC 2070 (Supplementary)

DECLARE FUNCTIONS rev$(n$)

INPUT “Any string”;n$

PRINT rev$(n$)

END

FUNCTION rev$(n$)

FOR x= LEN(n$) TO 1 STEP -1

A$=MID$(n$,x,1)

B$=b$+a$

NEXT x

Rev$=b$

END FUNCTION

a        List the library functions used in the above program.

An:    LEN (), MID$

b.       What will be the maximum value of x if the n$ is equal to “computer”

An:    8

 

29)    SLC 2071

DECLARE SUB stde(n$u)

FOR Loop = 1 to 5

READ nm$(loop)

NEXT loop

DATA RAMA, PRATIMA, PRASHANT

DATA NISHA, RUDHRA

CALL stde(NM$u)

END

SUB stde(N$u)

PRINT “Name starting from P”

FOR j= 1 to 5

C$=MID$(n$,(j),1,1)

IF c$=”P” THEN

PRINT n$(j)

ENDIF

NEXT j

END SUB

a)      List the library function used in the above program.

Ans:  Library function: MID$

b)      List the conditional statement used in above program.

Ans:  Conditional statement: IF c$=”P” THEN

 

30)    DECLARE SUB ABC(A,B,C)

INPUT P, Q, R

CALL ABC(P,Q,R)

END

SUB ABC(A,B,C)

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

PRINT “The middle number is”;A

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

PRINT “The middle number is”;B

ELSE

PRINT “The middle number is”;C

END IF

END SUB

a)      What is the alternative way of invoking the SUB module.

Ans:  The alternative way of invoking the SUB module is: ABC P, Q, R

b)      Make a list of operators and state their types.

Ans:  Lists of operators are:

          ·        Relational operator: < , >

          ·        Logical operator: AND , OR

 

31)    DECLARE FUNCTION SUM(N)

CLS

INPUT “Enter any number:-“;NUM

S=SUM(NUM)

PRINT “Sum of digits=”;S

END

FUNCTION SUM(N)

S1=0

DO WHILE N>=0

R=N MOD 10

N=INT(N/10)

LOOP

SUM=S1

END FUNCTION

a)      Are N and NUM used for the same purpose? Explain.

Ans:  No, NUM and N are not used for same purpose. NUM stores the input value whereas N receives the value stored in NUM.

b)      What will be the value of S1 if the value of NUM is 155?

Ans:  The value if S1 will be 11 if the value of NUM is 155.

 

32)    

DECLARE SUB TEST(A$)

CLS

INPUT R$

CALL TEST (R$)

END

SUB TEST (A$)

FOR I = 1 TO LEN(A$)

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

NEXT I

PRINT P$

END SUB

a.       Write the name of procedure used in the above program.

Ans:  The name of the procedure used in the above program is TEST

b.       List out all the numeric and string variables used in the above program.

Ans:  The numeric variables used are: I

          The string variables used are: R$, A$, P$

 

33)    DECLARE FUNCTION EVE(A)

CLS

FOR I = 1 TO 10

READ E

B=B+EVE(E)

NEXT I

PRINT NUMBER OF EVEN NUMBERS=”;B

DATA 3,4,2,5,22,33,67,76,88,65

END

FUNCTION EVE(M)

C= M MOD 2

IF C = 0 THEN

D=1

ELSE

D=0

END IF

EVE=D

END FUNCTION

a.       List out the types of parameters used in the program.

Ans:  The types of parameters used in the program are:

          i.       Actual Parameter (E )

          ii.      Formal Parameter(A)

b.       How many times will the function module be called?

Ans:  The function module will be called 10 times.

 

34)    SEE 2072

DECLARE FUNCTION Prod(N)

INPUT “Any number”;N

X=Prod(N)

PRINT X

END

FUNCTION Prod(N)

F=1

FOR K=1 TO N

F=F*K

NEXT K

Prod=F

END FUNCTION

a)      Write the name of the user defined function used in the above program.

Ans:  Prod

b)      Name the loop in the above program.

Ans:  FOR.....NEXT

 

35)    SEE 2073

DECLARE FUNCTION Diff(A, B)

CLS

INPUT “Enter first number”; A

INPUT “Enter second number”; B

PRINT “The difference”; Diff(A, B)

END

 

FUNCTION Diff(A, B)

Difference= A – B

Diff = difference

END FUNCTION

a.       List all the numeric variables used in the above program.

Ans:  The numeric variables used in the above program are A, B and Difference

b.       List the local variables used in the above program.

Ans:  The local variables used in the above program is A, B and Difference

 

36)    SEE 2073 Supp.

DECLARE FUNCTION sum(a,b)

INPUT a

INPUT b

x=sum(a,b)

PRINT x

END

 

FUNCTION sum(a,b)

s=a+b

sum=s

END FUNCTION

a)             Write the local variable used in the above FUNCTION procedure.

Ans:  a,b and s

b)             Write the mathematical and relational operator used in above prograam.

Ans:  Mathematical operator:     +

          Relational operator: =

 

37)    SEE 2074

DECLARE FUNCTION SUM (N)

CLS

INPUT "Enter any number"; N

S = SUM (N)

PRINT "The Sum of individual digit is"; S

END

 

FUNCTION SUM (N)

WHILE N > 0

R = N MOD 10

T = T + R

N = N \ 10

WEND

SUM = T

END FUNCTION

a)      State the purpose of suing variable S in line 4 in above program.

Ans:  Variable S is used to store the value returned by the function Sum.

b)      Write the use of MOD in the above program.

Ans:  MOD is used to get the remainder of the division.

 

38)    DECLARE FUNCTION ADD(N)

CLS

FOR CNT= 1 TO 3

READ NUM

PRINT ADD(NUM)

NEXT CNT

DATA 8, 7, 3

END

FUNCTION ADD(N)

S=0

FOR G= 1 TO N

S=S+G

NEXT G

ADD=S

END FUNCTION

a.       Name the actual and formal parameter used in above program.

Ans:  The actual parameter used in the above program is NUM and      formal parameter used in the above program is N.

b.       What is the value of NUM when the value of CNT is 2?

Ans:  The value of NUM when the value of CNT is 2 is 7.

 

39)    SEE 2075

DECLARE SUB SUM(N)

N = 5

CALL SUM (N)

END

 

SUB SUM(N)

FOR X = 1 TO N

S =S + X

NEXT X

PRINT S

END SUB

a)      In the above program how many times does the FOR ………..NEXT loop executes?

Ans:  The FOR ………..NEXT loop will execute 5 times.

b)      Write the name of the procedure used in the above program.

Ans:  The name of the procedure used in the above program is SUM.

 

40)    SEE 2075 (State 2)

DECLARE SUB TRIM(W$)

CLS

INPUT "Enter word"; WO$

CALL TRIM(WO$)

END

SUB TRIM (W$)

FOR I = 1 TO LEN(W$)

PRINT LEFT$(W$, I)

NEXT I

END SUB

a)      What will be the maximum value of I if input string is “SEE” in the above program?

Ans:  The maximum value of I will be 1 to 3 if input string is “SEE” in the above program.

b)      List the real parameter used in the above program.

Ans:  The real parameter used in the above program is WO$.

 

41) Grade Promotion Exam 2079

DECLARE FUNCTION prod (A,B)

CLS

INPUT "Enter first number";a

INPUT "Enter second number";b

PRINT "The product of the two numbers=";prod(a,b)

END

 

FUNCTION prod(a,b)

p=a*b

prod=p

END FUNCTION

i) List all the numerical variable used in the program above.

Ans: A,B, and P are the numerical variables used in the above program.

 

ii) List the local variable used in the above program.

Ans: P is the local variable used in the above program.

 

42)

Open "data.txt" for output As #1 

top:

Input "Enter name , class and Attendance" , n$,cl,A 

Write #1,n$,cl,A

Input "more records";y$ 

If y$="y" then 

goto top 

close #1

 End

a) Why is the file opened in output mode?

Ans: The file is opened in output mode to write data to it.

b) What will happen if the label top is placed above the OPEN statement?

Ans: Placing the label "top" above the OPEN statement would result in a logical error, causing repeated attempts to open the file without closing it and erasing previous data entries.


43)

DECLARE FUNCTION text$(N$)

CLS

INPUT “Enter any string”;X$

PRINT text$(X$)

END

FUNCTION text$(N$)

            FOR i=len (N$) TO 1 STEP -1

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

            NEXT i

            text$ = W$

END FUNCTION

a) What is the main objective of the program given above?

Ans: The main objective of the program is to reverse the input string.

b) List all the parameters used in the above program.

Ans: Formal parameter: n$  and Actual parameter: x$


     


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages