# Qbasic programs solutions(part 10) for class 8, class 9 and class 10

qbasic programs for class 8,9 and 10 part 10

Here, I have listed some of the qbasic programs. We also have mobile app where you can view all the qbasic programs. For better experience I highy recommend you to use our mobile app.

181  Write a program in qbasic to print all even numbers from 2 to 100 in descending order

``````CLS
FOR I = 100 TO 2 STEP - 1
PRINT I,
NEXT I
END ``````

182  Write a program in qbasic to ask any string and count total no. of consonants

``````CLS
INPUT "ENTER ANY STRING"; S\$
CC = 0
FOR I = 1 TO LEN(S\$)
B\$ = MID\$(S\$, I, 1)
C\$ = UCASE\$(B\$)
IF C\$  <> "A" AND C\$  <>  "E" AND C\$   <> "I" AND C\$  <>  "O"
AND C\$   <>  "U" AND C\$ <> " " AND C\$  <>  "." THEN
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF CONSONANTS= "; CC
END
﻿``````

183  Write a program in qbasic to generate the following series 11111   1111   111   11   1

``````CLS
A = 11111
FOR I = 1 TO 5
PRINT A
A = A \ 10
NEXT I
END
﻿``````

184  Write a program to input any number and check whether the given no. is positive or negative.

``````CLS
INPUT “ENTER ANY NUMBER”; N
IF N   > 0 THEN
PRINT N; IS POSITIVE NUMBER”
ELSEIF N < 0 THEN
PRINT N; IS NEGATIVE NUMBER”
END IF
END

﻿``````

185  Write a program in qbasic to generate the following series 2   3   5   8   13…………10th term

``````CLS
A = 2
B = 3
FOR I = 1 TO 10
PRINT A;
C = A + B
A = B
B = C
NEXT I
END
﻿``````

186  Write a program in qbasic TO ENTER ANY DIGIT AND PRINT SQUARE OF EVEN DIGITS

``````CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
WHILE N  <> 0
R = N MOD 10
IF R MOD 2 = 0 THEN S = S + R ^ 2
N = N \ 10
WEND
PRINT "SUM OF SQUARE OF EVEN DIGITS"; S
END
﻿``````

187  Write a program in qbasic to generate the following series 88888888   666666   4444   22

``````CLS
FOR I = 8 TO 2 STEP -2
FOR J = 1 TO I
PRINT I;
NEXT J
PRINT
NEXT I
END
﻿``````

188  Write a program in qbasic to print sum of square of any three ask numbers

``````REM PROGRAM TO DISPLAY SUM OF SQUARE OF ANY THREE INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = A ^ 2 + B ^ 2 + C ^ 2
PRINT “SUM OF SQUARE OF THREE NUMBERS ”; S
END
﻿``````

189  Write a program in qbasic to ask any string and check whether the given string is palindrome or not

``````CLS
INPUT "ENTER ANY STRING"; S\$
FOR I = LEN(S\$) TO 1 STEP -1
B\$ = MID\$(S\$, I, 1)
W\$ = W\$ + B\$
NEXT I
IF S\$ = W\$ THEN
PRINT  S\$; “IS PALINDROME”
ELSE
PRINT S\$; “IS NOT PALINDROME”
END IF
END
﻿``````

190  Write a program to input a year and display whether that year is a leap year or not.

``````CLS
INPUT “ENTER YEAR”; Y
IF Y MOD 4 = 0 AND Y MOD 100  < > 0 OR Y MOD 400 = 0 THEN
PRINT Y; IS LEAP YEAR”
ELSE
PRINT Y; IS NOT LEAP YEAR”
END IF
END
﻿``````

191  Write a program in qbasic to print all natural numbers from 1 to 100 also print its sum

``````CLS
FOR I = 1 TO 100
PRINT I,
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END
﻿``````

192  Write a program in qbasic to convert hexadecimal number to decimal number

``````CLS
FOR I = LEN(N\$) TO 1 STEP -1
B\$ = MID\$(N\$, I, 1)
IF B\$ = "A" THEN B\$ = "10"
IF B\$ = "B" THEN B\$ = "11"
IF B\$ = "C" THEN B\$ = "12"
IF B\$ = "D" THEN B\$ = "13"
IF B\$ = "E" THEN B\$ = "14"
IF B\$ = "F" THEN B\$ = "15"

S = S + VAL(B\$) * 16 ^ P

P = P + 1
NEXT I
PRINT "DECIMAL EQUIVALENT VALUE="; S
END
﻿``````

193  Write a program to input the age of a person and find out whether the person is eligible to drive or not.

``````CLS
IF A >= 16 THEN
PRINT “YOU ARE ELIGIBLE TO DRIVE”
ELSE
PRINT “ YOU ARE NOT ELIGIBLE TO DRIVE”
END IF
END
﻿``````

194  Write a program to enter any 20 numbers and display the greatest one using array.

``````REM
CLS
DIM N(20)
FOR I = 1 TO 20
INPUT "ENTER THE NUMBERS"; N(I)
NEXT I
G = N(1)
FOR I = 2 TO 20
IF N(I) > G THEN G = N(I)
NEXT I
PRINT “THE GREATEST NUMBER IS”; G
END
﻿``````

195  Write a program in qbasic TO PRINT L.C.M OF A GIVEN ANY TWO NUMBERS

``````CLS
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
IF N(I) MOD 2 = 0 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 EVENNUMBERS"; S
END
﻿``````

196  Write a program in qbasic to enter any 10 numbers and find the sum of even numbers

``````CLS
FOR I = 1 TO 10
INPUT "ENTER THE NUMBERS"; N(I)
IF N(I) MOD 2 = 0 THEN S = S + N(I)
NEXT I
PRINT "SUM OF 10 EVENNUMBERS"; S
END
﻿``````

197  Write a program to divide a number by another number and find the quotient and remainder.

``````CLS
INPUT "ENTER FIRST NUMBER"; A
INPUT "ENTER SECOND NUMBER"; B
IF A > B THEN
R = A MOD B
Q = A \ B
ELSE
R = B MOD A
Q = B \ A
END IF
PRINT "QUOTIENT="; Q
PRINT "REMAINDER ="; R
END
﻿``````

198  Write a program in qbasic using to print the sum of first ten positive integers

``````CLS
FOR I = 1 TO 10
S = S + I
NEXT I
PRINT “SUM OF FIRST  TEN POSITIVE INTEGERS” ; S
END
﻿``````

199  Write a program in qbasic to print cube root of an ask number

``````REM PROGRAM TO DISPLAY CUBE ROOT OF AN INPUT NUMBER
CLS
INPUT “ENTER ANY NUMBER”; N
C = N ^ (1 / 3)
PRINT “CUBE ROOT OF NUMBER ”; C
END
﻿``````

200  Write a program in qbasic to convert octal number to decimal number

``````CLS
INPUT "ENTER OCTAL NUMBER"; N\$
FOR I = LEN(N\$) TO 1 STEP -1
B\$ = MID\$(N\$, I, 1)
S = S + VAL(B\$) * 8 ^ P
P = P + 1
NEXT I
PRINT "DECIMAL EQUIVALENT VALUE="; S
END ``````