## COMPUTER SCIENCE SOLUTION OF GRADE 9

What is Q-BASIC Program? List its basic elements.

Q-BASIC is a high level programming language developed by Microsoft Corporation, USA for microcomputers in 1985. It uses Interpreter as a language translator program.  It uses a set of keywords and mathematical symbols to write programs. The programs written in QBASIC need to be converted into machine codes by using Interpreter.
Basic elements of QBASIC are listed below

• Variables
• Operators
• Keywords
• Character Sets
• Constants
• Expression and Syntax

Write a program to accept any 3 digit number from user and check whether it is an Armstrong number or not.

CLS
INPUT “Enter a number ”;n
m=n
WHILE n<>0
R=n mod 10
Sum=sum+R^3
N=n\10
WEND
IF M=Sum THEN
PRINT “It is an Armstrong number”
ELSE
PRINT “It is not an Armstrong number”
END IF
END

Write a program to display Fibonacci series 2,2,4,6,10,16,………,up to 10th terms.

CLS
A=2
B=2
FOR J=1 to 10
PRINT A;
C=A+B
A=B
B=C
NEXT J
END

Write a program to display the reverse word for any entered word by a user.

CLS
INPUT “Enter any word”;w\$
FOR j=LEN(n\$) TO 1 STEP-1
C\$=MID\$(n\$,j,1)
Rev\$=Rev\$+C\$
NEXT j
PRINT “The reverse word is ”;Rev\$
END

Write a program to find the greatest number among any 10 numbers entered by a user using an array.

CLS
OPTION BASE 1
DIM n(10)
PRINT “Enter any 10 numbers”
FOR j=1 TO 10
INPUT n(j)
NEXT j
FOR k=1 TO 10
IF n(k)>g THEN g=n(k)
NEXT k
PRINT “The greatest number is ”;g
END