Connect Me

twitterfacebookgoogle plus email

  Instagram View Biwas Bhattarai's profile on LinkedIn
Showing posts with label class 9 qbasic. Show all posts
Showing posts with label class 9 qbasic. Show all posts

SLC QBASIC- Array problems

WAP to ask user 20 different integers and print the sum of positive numbers only.

DECLARE SUB SUM(N())
DIM N(20)
CLS
PRINT "Enter 20 integers"
FOR I= 1 TO 20
INPUT "Number";N(I)
NEXT I
CALL SUM(N())
END

SUB SUM(N())
FOR J=1 TO 20
IF N(J)>0 THEN S=S+N(J)
NEXT J
PRINT "Sum of positive numbers is ";S
END SUB




WAP to ask user 10 different numbers and print the greatest number.

DECLARE SUB GREAT(N())
DIM N(10)
CLS
PRINT "Enter 10 numbers"
FOR I= 1 TO 10
INPUT "Number";N(I)
NEXT I
CALL GREAT(N())
END

SUB GREAT(N())
FOR J=1 TO 10
IF N(J)>G THEN G=N(J)
NEXT J
PRINT "Greastest number is ";G
END SUB

Reverse the word using QBASIC program


Qbasic Program to Reverse a string(word)
cls
b$="BIWAS"
c=LEN(b$)
for i= 1 to c
a$=mid$(b$,i,1)
r$=a$+r$
next i
print "Reverse"; "of"; b$; "is"; r$
end

OR


b$="BIWAS"
c=LEN(b$)
for i= c to 1 step -1
a$=mid$(b$,i,1)
r$=r$+a$
next i
print "Reverse"; "of"; b$; "is"; r$
end


QBASIC Program using DO LOOP UNTIL

Display the first 10 natural numbers using DO .... UNTIL LOOP

CLS
A=1
DO UNTIL A>10
PRINT A
A=A+1
LOOP
END

QBASIC Program to display prime digits of a supplied number

REM QBASIC Program to display prime digits of a supplied number
Declare Sub Disprime(n)
CLS
INPUT n
Call Disprime(n)
End
Sub Disprime(n)
m = n
PRINT "Prime digits are ";
WHILE n <> 0
r = n MOD 10
c = 0
n = n \ 10
FOR i = 1 TO r
IF r MOD i = 0 THEN c = c + 1
NEXT i
IF c = 2 THEN PRINT r
WEND
End SUB

SLC QBASIC Programs

Palindrome string



REM Program to check whether a supplied string is palindrome or not

CLS

INPUT "ENTER A STRING/WORD";N$

L=LEN(N$)

FOR I= 1 TO L

M$=MID$(N$,I,1)+M$

NEXT I

IF M$=N$ THEN

PRINT "THE SUPPLIED STRING IS PALINDROME"

ELSE

PRINT "THE SUPPLIED STRING IS NOT PALINDROME"

END IF

END


Ą
https://www.flickr.com/photos/spklg/15211044551/