Some programs

Print This Page
  1. Display initial letters.

Using Sub Procedure :

DECLARE SUB INI(S$)

CLS

INPUT “ENTER YOUR FULL NAME “; F$

CALL INI(F$)

END

SUB INI(S$)

P$=” “+S$ ‘ ADDS SPACE BEFORE STRING

FOR I = 1 TO LEN(S$)

A$=MID$(P$,I,1)

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

IF A$=” ” THEN C$=C$+B$

NEXT I

PRINT “YOUR NAME IN SHORT FORM : ” ; C$

END SUB

Using Function :

DECLARE FUNCTION INI$(S$)

CLS

INPUT “ENTER YOUR FULL NAME “; F$

PRINT INI$(F$)

END

FUNCTION INI$(S$)

P$=” “+S$ 

FOR I = 1 TO LEN(S$)

A$=MID$(P$,I,1)

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

IF A$=” ” THEN C$=C$+B$

NEXT I

INI$=C$

END FUNCTION

2. COUNT TOTAL NUMBERS OF WORD

Using Sub Procedure :

DECLARE SUB COUNT(S$)

CLS

INPUT “ENTER YOUR FULL NAME “; F$

CALL COUNT(F$)

END

SUB COUNT(S$)

C=1

FOR I = 1 TO LEN(S$)

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

IF B$=” ” THEN C=C+1

NEXT I

PRINT “TOTAL WORDS : ” ; C

END SUB

Using Function :

DECLARE FUNCTION COUNT(S$)

CLS

INPUT “ENTER YOUR FULL NAME “; F$

PRINT COUNT(F$)

END

FUNCTION COUNT(S$)

C=1

FOR I = 1 TO LEN(S$)

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

IF A$=” ” THEN C=C+1

NEXT I

COUNT=C

END FUNCTION