Thursday, October 17, 2019

138. Qbasic program to enter a long string and display only initial character of each word


138.      Write a program to enter a long string and display only initial character of each word Using function procedure.



DECLARE FUNCTION INIT$(A$)
CLS
INPUT "ENTER ANY STRING"; A$
PRINT INIT$(A$)
END
FUNCTION INIT$ (A$)
C$ = LEFT$(A$, 1)
FOR I = 1 TO LEN(A$)
    B$ = MID$(A$, I, 1)
    IF B$ = " " THEN C$ = C$ + MID$(A$, I + 1, 1)
NEXT I
INIT$ = C$

END FUNCTION

No comments:

Post a Comment