CLS

a = 1

b = 1

PRINT a, b,

FOR i = 1 TO 8

c = a + b

PRINT c,

a = b

b = c

NEXT i

END

……………………………………………………………………………….

2) WAP to print the factors of a given number

REM Program to print the factors of a given number

CLS

INPUT “Enter any number”; n

FOR i = 1 TO n

IF n MOD i = 0 THEN PRINT i,

NEXT i

END

…………………………………………………………………………………

3) WAP to print the greater among ten different numbers

REM Program to print greater number among ten different numbers CLS

INPUT “Enter first number”; g

FOR i = 2 TO 10

INPUT “Enter next number”; a

IF a > g THEN g = a

NEXT

PRINT g; ” is the greatest number”

END

…………………………………………………………………………………. 4) WAP to print the greater among three different numbers

REM Program to print greater among three different numbers

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

INPUT “Enter third number”; c

IF a > b AND a > c THEN

PRINT a; ” is greater”

ELSEIF b > a AND b > c THEN

PRINT b; ” is greater”

ELSE

PRINT c; ” is greater”

END IF

END

…………………………………………………………………………….

5) WAP to print the greater among two different numbers

REM Program to print the greater among two different numbers CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

IF a > b THEN

PRINT a; ” is greater”

ELSE

PRINT b; ” is greater”

END IF

END

……………………………………………………………………………….. 6) WAP to calculate the cube root of a given number

REM Program to calculate the cube root of a given number

CLS

INPUT “Enter any number”; n

c = n ^ (1 / 3)

PRINT “Cube root of “; n; ” is “; s

END

…………………………………………………………………………………..

7) WAP to calculate the square root of a given number

REM Program to calculate the square root of a given number

CLS

INPUT “Enter any number”; n

s = SQR(n)

PRINT “Square root of “; n; ” is “; s

END

1)Program to check the given number for palindrome in qbasic using declare sub

DECLARE SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

S = N

WHILE N 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

……………………………………………………………………………….. 2) Program to check given number for armstrong in qbasic using declare sub DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N 0

B = N MOD 10

R = R + B ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

………………………………………………………………………………….

3) Program to reverse a given string in qbasic

CLS

INPUT “ENTER A STRING”; S$

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

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

………………………………………………………………………………..

4) Program to convert decimal to binary in qbasic using declare function

‘THIS PROGRAM CONVERTS DECIMAL NUMBER TO BINARY

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

FUNCTION A$ (N)

WHILE N 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

…………………………………………………………………………………. 5) Program to convert decimal to octal in qbasic

THIS PROGRAM CONVERTS DECIMAL NUMBER TO Octal

CLS

INPUT “ENTER A NUMBER”; N

WHILE N 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N / 8)

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END

……………………………………………………………………………….

6)Program to reverse a given number in qbasic

CLS

INPUT “ENTER A NUMBER”; N

WHILE N 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

PRINT R

END...