Friday, December 30, 2016

Qbasic Program that accept the full name of the person and display the initial character of the first name and middle name with full family name.(eg.Meg Bahadur Thapa as M.B.Thapa)

Write a QBasic Program that accept the full name of the person and display the initial character of the first name and middle name with full family name.(eg.Meg Bahadur Thapa as M.B.Thapa)

CLS
INPUT "ENTER FULL NAME"; A$
B$ = LEFT$(A$, 1)
FOR J = 1 TO LEN(A$)
    C$ = MID$(A$, J, 1)
    IF C$ = " " THEN B$ = B$ + "." + MID$(A$, J + 1, 1)
NEXT J

FOR I = LEN(A$) TO 1 STEP -1
    D$ = MID$(A$, I, 1)
    F = F + 1
    IF D$ = " " THEN
        E$ = E$ + RIGHT$(A$, F - 2)
        EXIT FOR
    END IF
NEXT I

PRINT B$ + E$
END

15 comments:

  1. Thank u for uploading this post! It is really a big help.

    ReplyDelete
  2. I need MBT for Meg Bahadur Thapa

    ReplyDelete
    Replies
    1. https://seeqbasicomputer.blogspot.com/2019/10/138-qbasic-program-to-enter-long-string.html

      Delete
    2. CLS
      INPUT"full name"; N$
      IN$= MID$(N$, 1, 1)
      FOR I= 2 TO LEN(N$)
      IF MID$( N$, I, 1)= " "THEN
      IN$= IN$ + "."+ MID$(N$, i+1,1)
      END IF
      NEXT
      PRINT"The initials";IN$
      END

      Delete
  3. but what if i want to print middle name only out of the three words

    ReplyDelete
  4. Very very tq sir it's big help for me .... Thanks a lot

    ReplyDelete
  5. I think this will work out.
    CLS
    s$ = "Laxmi Prasad Devkota"
    PRINT LEFT$(s$, 1); ".";
    FOR i = 1 TO LEN(s$) STEP 1
    a$ = MID$(s$, i, 1)
    IF a$ = " " THEN PRINT MID$(s$, i + 1, 1); ".";: EXIT FOR
    NEXT i
    FOR j = LEN(s$) TO 1 STEP -1
    c$ = MID$(s$, j, 1)
    IF c$ = " " THEN
    PRINT RIGHT$(s$, LEN(s$) - j)
    EXIT FOR
    END IF
    NEXT j
    END

    ReplyDelete
  6. Write a program to input the first name and last name of the user and print their full name.

    ReplyDelete
  7. hello your program can be short and i have just a simple issue with your website that is i cannot copy and thing on your website so try to chance some of your codes and fix it other wise you may lost your viewers i just giving feedback

    ReplyDelete
  8. this program is holy wrong so don't copy it

    ReplyDelete