(IX) Analytical QBASIC Program

1. Study the following program and answer the given questions:

CLS INPUT A, B SUM=A+B PRINT "Sum of two numbers is " ; SUM END
  1. List all the numerical variables used in above program.
  2. Answer:A , B, SUM
  3. Write the mathematical operator and relational operator used in above program.
  4. Answer:
    Relational operator : Equal to (=)
    Arithmetic Operator: Addition(+)
  5. Write the operator name with its type.
  6. Answer:
    Relational operator : Equal to (=)
    Arithmetic Operator: Addition(+)
  7. Does the program run if CLS is removed
  8. Answer: Yes, the program runs.

2. Study the following program and answer the given questions:

CLS INPUT "Enter a number"; N F=1 FOR I = N TO 1 STEP -1 F = F * I NEXT I PRINT "Factorial of " ; N; " = "; F END
  1. Write down the use of line F=1.
  2. Answer: F is used as an integer constant which value is 1.
  3. Name the loop used in above program.
  4. Answer: FOR- NEXT LOOP
  5. Write the mathematical operator and relational operator used in above program.
  6. Answer:
    Relational operator : Equal to (=)
    Arithmetic Operator: Multiplication (*)

3. Study the following program and answer the given questions:

CLS INPUT N R = N MOD 2 IF R = 0 THEN PRINT "EVEN NUMBER" ELSE PRINT "ODD NUMBER" END IF END
  1. List all the numeric variables used in above program.
  2. Answer: N, R
  3. What will be the value of R, if N=10?
  4. Answer: Value of R will be zero.
  5. What is the function of MOD ?
  6. Answer: MOD is used to find the remainder.
  7. What is the meaning of R= N MOD 2 in above program?
  8. Answer: R= N MOD 2 means the remainder will be stored in R varaible when given number(N) is divided by 2.

4. Study the following program and answer the given questions:

CLS W$= "PURUSHOTTAM" FOR I = 1 TO LEN(W$) STEP +2 PRINT MID$(W$,I,1) NEXT I END

  1. Write the names of two built in or Library functions used in above program.
  2. Answer: LEN, MID$
  3. Name the loop used in above program.
  4. Answer: FOR – NEXT LOOP
  5. What will be the maximum value of I if the w$ is equal to "Computer".
  6. Answer: Eight
  7. What will be the output of above program.
  8. Answer:
    P R S O T M
    P U R U S H O T T A M
    1 2 3 4 5 6 7 8 9 10 11

5. Study the following program and answer the given questions:

CLS X=10 FOR P = 1 TO X PRINT P NEXT P END PRINT "PLK computer SIR"
  1. How many times does the loop execute in above program.
  2. Answer: Ten times
  3. Will "PLK computer SIR" appear in output screen?
  4. Answer: No, it won’t appear.