Friday, September 28, 2018

QBASIC PROGRAM - Analytical Programs - Computer Science [SLC / SEE] with answers







   
1. DECLARE SUB TEST(A, B, C)
LET X=4
LET Y=7
LET Z=12
CALL TEST (X, Y, Z)
PRINT X, Y, Z
END

SUB TEST(A, B, C)
A=A+3
B=B+2
SUM=A+B+C/3
PRINT SUM
END SUB

i) What happens if CALL TEST(X, Y, Z) is replaced by CALL TEST(A, B, C)
Ans: If CALL TEST(X, Y, Z) is replaced by CALL TEST(A, B, C) then the output will be:
5                  
4         7         12

ii) List the formal and real parameters used in the above program.
Ans: Formal Parameters = A, B, C
        Real Parameters = X, Y, Z

2.      DECLARE SUB word(B$)
CLS
A$ = “Computer science”
B$ = “Computer Programming”
Call word(a$)
Print A$
Call word (B$)
End

SUB WORD (c$)
L = LEN(C$)
post = (80 – L)/2
Print tab (post); C$
C$ = “examination”
END SUB
                                                                                                                                                                                                                                                                                             
i)Write the output of the above program.
Ans: The output of the program is:
                              Computer Science
examination
                            Computer Programming
ii) How is the arguments passed?
Ans: Argument is passed by reference
iii) What will the print A$ statement in module print?
Ans: A$ statement will print examination.
iv) Is C$ actual or formal parameter?
Ans: C$ is formal parameter




3.      DECLARE SUB question (a, b, c)
CLS
x=10  : y=20 : z=15
CALL question (x, y, z)
END
SUB question (a, b, c)
a=a+10
b= b + a
c=a +b
PRINT a, b, c
END SUB
i. Write actual and formal parameter used in the program.
Ans: Actual parameter = x, y, z
         Formal parameter = a, b, c
ii. What would be its output if x=1, y=2,z=3?
Ans: The output will be:
11              13              24

4.      DECLARE SUB SEQUENCE (A,B,C)
CLS
X=10
Y=20
Z=30
CALL SEQUENCE (X,Y,Z)
END

SUB SEQUENCE (C,B,A)
PRINT A,B,C
END SUB
i. List the formal parameters and actual parameters used in the above program.
Ans: Formal parameter = C, B, A
        Actual parameter = X, Y, Z
ii. Will the above program execute if the position of parameter is to be changed? If ‘yes’ then which sequence of number list will it print either 10,20,30 or 30,20,10?
Ans: it will print 30, 20, 10

5.      DECLARE SUB ADD(A,B)
CLS
INPUT “ENTER TWO NUMBERS”; X,Y
CALL ADD(X,Y)
END
SUB ADD(A,B)
C = A + B
PRINT “Sum is”; C
END SUB
i. Write the name of procedure in above program.
Ans: The name of the procedure is ADD.
ii. List arguments and parameters in the above program.
Ans: Arguments = X, Y
        Parameters= A, B



6.      DECLARE SUB TEST (A, B, C)
LET X = 4
LET Y = 7
LET Z = 12
CALL TEST (X, Y, Z)
PRINT X, Y, Z
END
SUB TEST (A, B, C)
A=A+3
B=B+2
SUM=A+B+C/3
PRINT SUM
END SUB
i. What will be the output of the above program?
Ans: The output is:
20
7         9           12

ii. List the arguments and parameters used in the above program.
Ans: Arguments = X, Y, Z
        Paramarers = A, B, C

7.      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

i. Name the actual and formal parameter used in above program.
Ans: Actual parameter = NUM
         Formal parameter = N

ii. What is the value of NUM when the value of CNT is 2?
Ans: The value of NUM will be 7 when the value of CNT is 2.

8.      DECLARE SUB RESULT (N)
CLS
INPUT "ENTER ANY NUMBER"; NUM
CALL RESULT (NUM)
END
SUB RESULT (N)
DO UNTIL N = 0
R = N MOD 10
IF R MOD 2 = 0 THEN
S = S + R
END IF
N = N \ 10
LOOP
PRINT S
END SUB

i. List the actual and formal parameters in the above program.
Ans: Actual parameter = NUM
         Formal parameter = N
ii. What will be the output of the program if the input is 1234?
Ans: The output is
6

9.      [SLC 2069]
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$,1)
NEXT I
END SUB

i. Write the names of two built in functions used in the program.
Ans: The names of two built in functions are LEN and RIGHT$
ii. List the real parameter and formal parameter in the program.
Ans: The real parameter is WO$ and formal parameter is N$






10.   DECLARE SUB RESULT (TXT$)
TEXT$ = "SYSTEM PROGRAMMING"
CALL RESULT (TEXT$)
END

SUB RESULT (TXT$)
FOR I = 1 TO LEN(TXT$)
SCAN$ = UCASE$(MID$(TXT$, I, 1))
IF I MOD 2 = 0 THEN
TEMP$ = TEMP$ + UCASE$(SCAN$)
ELSE
TEMP$ = TEMP$ + LCASE$(SCAN$)
END IF
NEXT I
PRINT TEMP$
END SUB
i.What is the output of the above program?
Ans: The output is
sYsTeM PrOgRaMmInG
ii.List the actual and the formal parameters used in the program.
Ans: The actual parameter is TEXT$ and formal parameter is TXT$


11.   DECLARE FUNCTION NUM(N)
CLS
N=14
PRINT NUM(N)
END

FUNCTION NUM(N)
WHILE N<>0
R=N MOD 2
S=S+R*10^P
P=P+1
N=N\2
WEND
NUM=S
END FUNCTION

i. List the local variable used in the function procedure.
Ans: The local variables are N, R, S and P
ii. What will be the output if the program?
Ans: The output is:
1110



12.   DECLARE SUB TEST(A,B)
CLS
X=2: Y=2
CALL TEXT(X,Y)
PRINT X,Y
END
SUB TEST(P,Q)
FOR I= P TO Q
P=P+Q
Q=P+Q
NEXT
PRINT P,Q
END SUB
i. What will be the output of the above program?
Ans: The output is
4       6
4       6
ii. List down the global variable used in the above program.
Ans: The global variables are X and Y

13.   DECLARE SUB SERIES(A, B)
DECLARE FUNCTION SUM(P,Q)
COMMON SHARED N
INPUT “Enter First Term”;X
INPUT “Enter Second Term”;Y
INPUT “Enter Number of Terms to be generated”; N
CALL SERIES(X, Y)
END
SUB SERIES (A, B)
FOR I = 1 TO N
PRINT A
A=SUM(A,B)
NEXT I
END SUB
FUNCTION SUM (P,Q)
SUM=P+Q
END FUNCTION
i. What will the output if X=10, Y=8 and N=5.
The output is
10
18
26
34
42
ii. List out the local variables and global variable in the above program.
Ans: Local variables = A, B, I, P and Q
         Global variables = X, Y and N
14.   DECLARE SUB SERIES(X, Y, Z)
DECLARE FUNCTION SUM(X, Y)
DIM SHARED I
CLS
INPUT “Enter First Term”;X
INPUT “Common Difference”;Y
INPUT “Enter Number of Terms to be generated”; Z
CALL SERIES(X, Y, Z)
END

SUB SERIES (X, Y, Z)
FOR I = 1 TO Z
PRINT X
X = SUM(X, Y)
NEXT I
END SUB
FUNCTION SUM (X, Y)
SUM=X+Y
END FUNCTION
a)     What will be the output of the program if the user inputs 2, 3, 4 for the variables X, Y, Z respectively?
Ans: The output is:
2
5
8
11
b)     How many times the function SUM(X, Y) will be executed if the values of X, Y, Z are 2, 4, 6 respectively?
Ans: The function will execute 6 times.
c)      What type of variables X, Y and I are?
Ans: X, Y and I are numerical variables.
d)     Will the program run if the value of Z is less than X and Y?
Ans: Yes, the program will run.

15.   [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 the above program.
Ans: The name of the function is Num.
ii. List out the mathematical function (Library function) used in the above program.
Ans: The library function is Int( )

16.   [SLC 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
a) What is the name of the function used in the above program?
Ans: The name of the function is xyz
b) How many times the function will be called in the above program?
Ans: The function will be called 5 times.
17.   DECLARE FUNCTION count (S$)
CLS
INPUT"ENTER ANY STRING:";S$
PRINT "Number of words="; count (S$)
END

FUNCTION count (S$)
C=1
FOR I=1 TO LEN (S$)
A$= MID$(S$, I, 1)
IF A$="  " THEN C=C+1
NEXT I
count = C
END FUNCTION
a)     What is the name and type of function in above program?
Ans: The name of the function is count and type of function is user defined function.
b)     What will be the output if value of S$="I am a robot"?
Ans: The output is:
Number of words=4
c)      How many time loops will execute if value of s$="Sunder Nepal".
Ans: Loop will execute 12 times.

18.   [SLC 2065 S]
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 enters 200 as the first number and 100 as the second number.
Ans: The output is:
The difference of the two number=100
ii. Will the program run if the first line (i.e. DECLARE…..) is deleted?
Ans: Yes, the program will run if the first line (i.e. DECLARE…) is deleted.

19.   [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 are A, B and difference.
b)     List the local variables used in the above program.
Ans: The local variables are A, B and difference
20.   [SLC 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 above program.
Ans: The name of the user defined function used in above program is Prod.
b)     Name the loop in above program?
Ans: The name of loop is FOR….NEXT loop.

[SLC 2069 S]
21.   DECLARE FUNCTION CHK$(N)
CLS
N=57
PRINT “The number is”; CHK$(N)
END

FUNCTION CHK$(N)
FOR I = 1 TO N
IF N MOD I = 0 THEN C=C+1
NEXT I
IF C>2 THEN
CHK$=”Composite”
ELSE
CHK$=”Prime”
END IF
END FUNCTION

i. Will the above program execute if “DECLARE FUNCTION….” is deleted.
Ans: Yes, the program will run if the first line (i.e. DECLARE…) is deleted.
ii. Why $ sign is used in the name of the above function.
Ans: $ sign is used in the name of the above function because the function returns string value.


22.   DECLARE FUNCTION SHAPE$(TXT$)
CLS
INPUT ”Enter a string”; T$
RV$=SHAPE$(T$)
PRINT “The text in reverse order is”; RV$
END

FUNCTION SHAPE$(TXT$)
FOR I = LEN(TXT$) TO 1 STEP -1
CH$=MID$(TXT$,I,1)
R$=R$+CH$
NEXT I
SHAPE$=R$
END FUNCTION
i. Write the library functions used in the above program.
Ans: The library functions are LEN( ) and  MID$( )
ii. Write the use of expression SHAPE$=R$ written at the end of the function procedure.
Ans: The use of the expression is to return the value to the calling function procedure.

23.   [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
End if
Next K
Count = X
End function
i) List any two library functions used in the above program.
Ans: Any two library functions are LEN( ) and MID$( ).
ii) Write the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.
Ans: The use of variable ‘C’ is to store the value returned by the function count.

24.   [SLC 2066 S]
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
END IF
NEXT I
COUNT=C
END FUNCTION

i. List the string Library functions used in the above program.
Ans: The string Library functions used in the above program are LEN( ), UCASE$( ) and MID$( ).
ii. Write down the missing statements in the main module to execute the program.
Ans: The missing statements in the main module to execute the program is PRINT COUNT(W$)

25.    [SLC 2071]
DECLARE SUB Stde(N$U)
FOR Loop = 1 TO 5
READ NM$(Loop)
NEXT Loop
DATA RAMA, PRATIMA, PRASANT
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)
END IF
NEXT J
END SUB
i. List the library function used in the above program.
Ans: The library function used in the above program is MID$( ).
ii. List the conditional statement used in the above program.
Ans: The conditional statement used in the above program is IF….THEN.


26.   [SLC 2068 S]
DECLARE SUB ABC(X,Y,Z)
FOR P=1 TO 3
READ A,B,C
CALL ABC(A,B,C)
NEXT P
DATA 5,4,3,2,1,6,7,8,4
END
SUB ABC(X,Y,Z)
T=X+Y+Z
IF T MOD 2 = 0 THEN
PRINT T
END IF
END SUB
i. List any two variables used in the above program.
Ans: Any two variables used in the above program are X and Y
ii. How many times SUB-procedure will be called when program is executed?
Ans: The SUB procedure will be called 3 times.

27.   DECLARE FUNCTION B(N)
CLS
LET N = 12345
PRINT "Sum of Digits :"; B(N)
END
FUNCTION B(N)
WHILE N <> 0
R = N MOD 10
C = C+R
N = INT(N/10)
WEND
B = C
END FNCITON
i. Write the variables used in the program with their type.
Ans: Numeric variables = N, R and C
ii. List out the different types of operators with their type used in the program.
Ans: Arithmetic Operator = MOD, + and /
        Relational Operator = < > and =

28.   DECLARE SUB WORD (N$)
CLS
N$="PABSON”
CALL WORD (N$)
END
SUB WORD (N$)
B=LEN (N$)
C=1
WHILE C < B
M$=MID$(N$, C, 1)
PRINT M$
C=C+2
WEND
END SUB

i) List the string and numeric variables used in the program.
Ans: String variables = N$ and M$
         Numeric variables = C and B
ii) What is the value of B in the above program?
Ans: The value of B = 6

29.   DECLARE SUB Exam()
CLS
CALL Exam
END
SUB Exam
LET X=567
LET Y= X MOD 10
LET X1= INT(X/10)
LET Y1=X1 MOD 10
LET X2 = INT(X/10)
LET A =X2+Y1+Y
PRINT “The result is:”;A
END SUB

i. List the mathematical operators used in the above program.
Ans: Mathematical operator = MOD, / and +
ii. Write the value of variable A.
Ans: Tha vale of A is 69

30.   DECLARE FUNCTION CUBE(T,R)
CLS
N=15
S=CUBE (2,4)
PRINT “CUBE=”; S
END

FUNCTION CUBE(P, M)
CUBE = P^3
N = 5 * 2
END FUNCTION

i. How many parameters are used in above program?
Ans: One parameter is used.
ii. List two mathematical operators used in the above program.
Ans: Any two mathematical operators are ^ and *.

31.   DECLARE SUB TEST(A$)
CLS
INPUT “Enter a String”; B$
CALL TEST(B$)
END

SUB TEST(C$)
FOR I=1 TO LEN(C$)
D$ = MID$(C$,I,1)
E = ASC(D$)
IF E MOD 2 = 0 THEN
W$ = W$ + UCASE$(D$)
ELSE
W$ = W$ + LCASE$(D$)
ENDIF
NEXT I
PRINT W$
END SUB

i. List out the different parameters used in the program and mention its types.
Ans: Formal parameter = C$
         Actual parameter = B$
ii. Write the different operators used in the program and mention its types.
Ans: Arithmetic operator= MOD
         Relational operator = “=”
         String operator = +
iii. What is the function of CALL TEST(B$) statements?
Ans: To pass control to the sub procedure.
iv. What will be the output if users entered NEPAL?
Ans: The output is
NePaL

32.   DECLARE FUNCTION A(X)
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

a) How many parameters are used in the program?
Ans: One parameter is used.
b) How many times execute the expression S=S+I in the above program?
Ans: The expression S=S+I will be executed five times in the above program
c) If the line S = S + I is changed to S = S + I ^ 2 then find the output.
Ans: The output is:
15


33.   DECLARE FUNCTION Highest (M, N)
CLS
M=5 : N=10
PRINT Highest (M, N)
END

FUNCTION Highest(T,P)
While P<>0
R=T MOD P
T=P
P=R
Wend
Highest=T
End Function
i.What is the value the function returns in this program?
The function will return the value 5.
ii.What will happen if R=T Mod P is replaced by R=P MOD T?
Ans: The output is
10

34.   DECLARE FUNCTION B (N)
INPUT “ENTER A NUMBER”; N
PRINT “THE EQUIVALENT NUMBER IS = “; B(N)
END

FUNCTION B (N)
WHILE N<>0
r = N MOD 2
j$ = STR$(r)
SUM$ = j$ + SUM$
N = N\2
WEND
B = VAL(SUM$)
END FUNCTION

i. What will be the output of the program, if the value is 9?
The output is
9
ii. What is the use of VAL function in the above program?
VAL will convert the string value to numeric value.

35.   DECLARE FUNCTION RESULT(N)
PRINT RESULT(16)
END



FUNCTION RESULT(N)
WHILE N<>0
A=N MOD 2
N=N\2
E$=STR$(A)
F$=E$+F$
WEND
RT= VAL(F$)
RESULT=RT
END FUNCTION

i.Write the output of the above program.
Ans: The output is
10000
ii.What happens if we write the statement F$=E$+F$ as F$=F$+E$
Ans: The output is
1

36.   DECLARE FUNCTION SUM(N)
CLS
FOR I=1 TO 3
READ N
DATA 15,25,67
PRINT SUM (N)
NEXT
END

FUNCTION SUM(N)
S=0
WHILE N<>0
R=N MOD 10
S=S+R
N=INT(N/10)
WEND
SUM=S
END FUNCTION

i. What will be the output of the program?
Ans: The output is:
6
7
13
ii. How many times the main function will be called in this program?
Ans: The main function will be called three times in this program






37.   DECLARE FUNCTION HIGHEST (M, N)
CLS
M=5
N=10
PRINT HIGHEST(M,N)
END

FUNCTION HIGHEST(T,P)
WHILE P<>0
R=T MOD P
T=P
P=R
WEND
HIGHEST =35
END FUNCITON

a)     Write down the use of MOD in the above program.
Ans: The use of MOD operator is to return the remainder
b)     What is the value the function returns in this program?
Ans: The function returns the value 35.

38.   DECLARE SUB OUTPUT (A$)
X$=”COMPUTER SCIENCE”
END

SUB OUTPUT (A$)
L=LEN(A$)
FOR I= L TO 1 STEP-5
PRINT MID$(A$,I,1);
NEXT I
END SUB

i.What statement should be added in the main module to execute program?
Ans: CALL OUTPUT(X$) should be added in the main module to execute program
ii.What will be the output of the program after correcting the bugs?
Ans: The output is:
ECTC


39.   [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
a)     In which condition the statements within the WHILE….WEND looping statement will not be executed?
Ans: When the Value of N=0, the statements within the WHILE….WEND looping statement will not be executed
b)     Will the output be the same if we place “/” instead of”\” in the above program.
Ans: No. the output will not same if we place “/” instead of”\” in the above program.

40.   DECLARE SUB take(x, y)
CLS
FOR i = 1 TO 5
READ c, d
CALL take(c, d)
NEXT i
DATA 13, 15, 16, 12, 31, 12, 16, 17, 21, 22
END
SUB take(a, b)
STATIC s
IF a > b THEN
s = s + a
ELSE
s = s + b
END IF
PRINT s;
END SUB

a)     If the statement STATIC s is removed, then what will be the change in its output?
Ans: The statement STATIC s is removed, then the output will be:
15      16      31     17       22

b)     List out the formal arguments and actual arguments from the above program.
Ans: Formal arguments = a, b
         Actual arguments = c, d



41.   DECLARE FUNCTION SUM%(A AS INTEGER, B AS INTEGER)
DIM A AS INTEGER, B AS INTEGER
INPUT “Enter the first number”; A
INPUT “Enter the second number”; B
PRINT “The sum of the two nos=”; SUM(A, B)
END

FUNCTION SUM%(A AS INTEGER, B AS INTEGER)
VALUE% = A + B
SUM% = VALUE%
END FUNCTION

a)     Write the output of the program if the user inputs 10 for the first and 10.5 for the second number.
Ans: The sum of the two nos= 20
b)     What type of value will the function return?
Ans: The function will return integer value.

42.   [SLC 2064]
DECLARE FUNCTION CELLS$(W$)
W$=”CYBER”
PRINT CELL$(W$)
END
FUNCTION CELL$
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 the function name?
Ans: $(dollar) sign followed in the function name because the function returns string value.
b)     What will be the output of the program when it is executed?
Ans: The output is
CBR
c)      What will be the output of the program when FOR loop is changed as FOR I= 1 TO K STEP 2?
Ans: The output is
RBC
d)     What is the name of sign “+” used in the program and what operation does it perform?
Ans: The name of sign “+” is string operator and it is used to join the string i.e. string concatenation.

43.   [SLC 2070]
DECLARE FUNCTION Sum(A,B)
INPUT “Enter first number:”; A
INPUT “Enter second number:”; B
PRINT “The sum of the two number=”;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: The numerical variables used in the above program are S, A and B.
b) Will the program run if the first line (i.e. DECLARE….) is deleted?
Ans: Yes, the program will run if the first line (i.e. DECLARE….) is deleted

44.   [SLC 2070 S]
DECLARE FUNCTION 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 function used in the above program.
Ans: The library function used in the above program are LEN( ) and MID$( )
b.     What will be the maximum value of X if the N$ is equal to "Computer".
Ans: be the maximum value of X if the N$ is equal to "Computer" is 8.

45.   [SLC 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.
State the purpose of using variable S in line 4 in above program.
Ans: The purpose of using variable S in line 4 in above program is to store the value returned by the function SUM.
Write the use of MOD in above program.
Ans: The use of MOD operator is to return the remainder.



***



12 comments:

  1. Sir will you please upload some important QBASIC Programs(Specially writing ones) for SEE.

    ReplyDelete
    Replies
    1. its uploaded..check right side...all manual i have uploaded

      Delete
  2. Sir would u please explain me about the answers of Q.19 . . About numeric variable and local variables ??

    ReplyDelete
    Replies
    1. numeric variable means storing numbers and local variable means used within a sub procedure

      Delete
  3. a. DECLARE SUB Result()
    CALL Result
    END
    SUB Result()
    V=5
    C=1
    WHILE C<=5
    PRINT V,V^C
    WEND
    END SUB
    Can someone answer???

    ReplyDelete
    Replies
    1. Its infinte loop so its output will be:
      5 5
      5 5
      it will be display in that pattern infinte times and program will be running all the time so increase the value of c inside WHILE .... WEND loop
      i.e c = c +1

      Delete
  4. Write a program to input temperature in celcius degree and convert into temperature in fahrenheit degree using SUB...END SUB

    ReplyDelete
  5. Write the output of the following program.


    CLS

    LET n=25

    LET X = n + 20

    LET y=n^ * 3

    LET z = n - 5

    LET a = (x + z) - y

    PRINT a

    END

    ReplyDelete