PW 6
PW 6
Submitted by:
Class
Roll no:
# Project 1
CLS
PRINT “Date zone”
d$ = DATE$
month = VAL(MID(d$ , 2))
date = VAL(MID$(d$ , 4 , 2))
year = VAL(RIGHT$(d$ , 4))
PRINT d$
PRINT date
PRINT year
PRINT : PRINT
PRINT “Time zone”
t$ = Time$
hour = VAL(MID$(t$, 2))
minute = VAL(MID$(t$, 4 , 2))
second = VAL(RIGHT$(t$, 2))
PRINT t$
PRINT minute
PRINT second
END
#Project 2
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 w$ = s$ THEN
PRINT s$; “ is palindrome”
ELSE
PRINT s$; “ is not palindrome
ENDIF
END
#Project 3
CLS
INPUT “enter any string”; s$
RC = 0
FOR I = 1 TO LEN(s$)
B$ = MID$(s$, I, 1)
C$ = UCASE$(B$)
IF C$ = “R” THEN RC = RC + 1
NEXT I
PRINT “Total no. of ‘R’ =”; RC
END
#Project 4
CLS
INPUT “Enter a word “;a$
FOR I = 1 to LEN(a$)
B$ = MID$(a$, I, 1)
IF I mod 2 = 0 THEN
b$ = LCASE$(b$)
ELSE
b$ = UCASE$(b$)
END IF
alt$ = alt$ + b$
NEXT I
PRINT “the alternate word is “; alt$
END
#Project 5
CLS
INPUT “Enter any string “; s$
A$ = LEFT$(s$, 1)
B = ASC(A$)
IF B>= 48 AND B <= 57 THEN
PRINT “the input string is a number”
ELSEIF B>= 65 AND B<= 90 THEN
PRINT “the input string is uppercase”
ELSEIF B>= 97 AND B<= 122 THEN
PRINT “the input string is lowercase”
ELSE
PRINT “the characters are neither number nor
uppercase or lowercase”
END IF
END
#Project 6
CLS
a$ = “QBASIC”
t=8
for I = 1 to LEN(a$)
PRINT TAB(t); MID$(a$, I, 1)
T=t–1
NEXT I
END
#Project 7
CLS
A$ = “AISHWARYA”
T=1
FOR I = LEN(A$) TO 1 STEP -2
PRINT TAB(T); MID$(A$, T, I)
T=T+1
NEXT I
END
#Project 8
To input any 10 numbers and display
them by sorting in ascending order
CLS 1
DIM num(10)
FOR i = 1 to 10
INPUT num(i)
NEXT i
FOR j = 1 to 10
IF num(k) > num(k+1) THEN SWAP num(k), num(k+1)
NEXT k
NEXT j
PRINT “*********Sorted Data*********”
FOR z = 1 to 10
PRINT num(z)
NEXT z
END
#Project 9
To input any 5 names and display them in
ascending order by sorting
CLS
DIM n(5) AS STRING
FOR i = 1 TO 5
INPUT n(i)
NEXT
FOR i = 1 TO 5
FOR j = 1 TO 5 -1
IF n(j) > n(j+1) THEN
t$ = n(j)
n(j) = n(j + 1)
n(j+1) = t$
END IF
NEXT j
NEXT i
CLS
PRINT “*********Sorted name*********”
FOR x = 1 TO 5
PRINT n(x)
NEXT
END
#Project 10
Program to display the tabular form using
multi dimensional array with their column-wise
coloumn.
CLS
DIM num(3, 4)
FOR i = 1 TO 3
FOR j = 1 to 4
READ num(i, j)
PRINT num (i, j),
NEXT
PRINT
NEXT
PRINT “-------------------------------------------------------------“
FOR i = 1 TO 4
S=0
FOR j = 1 TO 3
S = s+ num(j, i)
NEXT j
PRINT s,
NEXT i
DATA 2,4,5,7,8,9,1,3,6,8,1,3
END
#Project 11
Program to display the tabular form usingmulti
dimensional array with their row and coloumn-
wise column
CLS
DIM num(3, 4)
FOR i = 1 TO 3
S= 0
FOR j = 1 to 4
READ num(i, j)
PRINT num(i, j),
s= s + num(i, j)
NEXT
PRINT “=”;s
NEXT
PRINT “----------------------------------------------“
FOR i = 1 TO 4
s=0
FOR j = 1 TO 3
s = s + num(j, i)
NEXT j
PRINT s,
NEXT i
DATA 2,4,5,7,8,9,1,3,6,8,1,3
END
#Project 12
To input number of tickets and destination and
calculate the bus fair with the help of following
table
Destination Amount
Nepalgunj 300
Butwal 600
Narayanghat 1000
Kathmandu 1400
CLS
PRINT ”1.Nepalgunj”
PRINT “2. Butwal”
PRINT “3.Narayanghat”
PRINT “4. Kathmandu”
INPUT “Enter number of tickets”; p
INPUT “enter your destination( 1 – 3)”; d
SELECT CASE d
CASE 1
r= 300
t=p*r
ta = t
CASE 2
r= 600
t = p *r
ta = t
CASE 3
r = 1000
t=p*r
ta = t
CASE 4
r = 1400
t=p*r
ta = t
CASE ELSE
PRINT “ please enter number between (1 – 3)
END SELECT
PRINT “total bus fare = “; ta
END
#Project 13
CLS
a=2
b=2
for p = 1 to 10
PRINT a;
c=a+b
a=b
b=c
NEXT p
END
#Project 14
To display :
1
22
333
4444
55555
CLS
FOR i = 1 TO 5
FOR j = 1 TO i
PTINT i;
NEXT j
PRINT
NEXT i
END
#Project 15
10 20 30 40 50
20 30 40 50 60
30 40 50 60 70
40 50 60 70 80
50 60 70 80 90
CLS
FOR p = 0 TO 4
FOR q = 1 TO 5
PRINT (p + q) * 10;
NEXT q
PRINT
NEXT p
END