QBASIC QUESTION SLC SET-1

A. Answer the following questions from programming:

  1. What is a variable? Mention its types.
  2. Read the following program and answer the following questions:


DECLARE FUNCTION check(a)
CLS
FOR i=1 TO 4
     READ n
     IF check(n)=1 THEN
         PRINT n
     END IF
NEXT i
DATA 256,432,125,361
END

FUNCTION check(n)
 s=SQR(n)
IF s=INT(s) THEN
  check=1
ELSE
  check=0
END IF
END FUNCTION


  1. What is the output of the above program?
  2. Does the program give output if INT( ) function is replaced by FIX( ) function?
  3. If FOR i=1 TO 4 is changed as FOR i=1 TO 5, then will the program run? why?
  4. Replace the FOR ...NEXT loop with WHILE ...WEND loop.



3. Write down the output of the following progam.

FOR i=1 TO 10
   READ N
   B=N MOD 5
   IF B=0 THEN
      c=c+1
  END IF
NEXT i
DATA 7,15,6,10,15,32,8,22,5
PRINT c
END

4. Rewrite the following program correcting the bugs:

REM to print given name 20 times
LET c=1
INPUT "Enter Name ;N$
WHILE c less or equal to 20
PRINT N$
c+1=c
END

5. Write a program that allows entering a number and checks whether the supplied number is positive,negative or zero using SUB...END SUB.

6. Write a program to calculate the area of a triangle whose three sides a,b,c is given from the keyboard using FUNCTION...END FUNCTION



Comments