WAP using SUB procedure to enter a string and print the characters of even position only. (Example: KATHMANDU, output is AHAD)
DECLARE SUB EVEN(E$)
CLS
INPUT "INPUT A WORD/STRING";E$
CALL EVEN(E$)
END
SUB EVEN(E$)
FOR I=1 TO LEN(E$)
F$=MID$(E$,I,1)
IF I MOD 2=0 THEN PRINT F$;
NEXT I
END SUB
Showing posts with label SEE QBASIC Nepal. Show all posts
Showing posts with label SEE QBASIC Nepal. Show all posts
WAP to enter multi-digits numbers and print only even numbers from them. (If input is 5481, output is 4,8)
DECLARE SUB SUM(N)
CLS
INPUT "ENTER MULTI-DIGITS NUMBER";N
CALL SUM(N)
END
SUB SUM(N)
WHILE N<>0
R=N MOD 10
IF R MOD 2=0 THEN PRINT "EVEN DIGIT IS "; R
N=N\10
WEND
END
Subscribe to:
Posts (Atom)




