Title: New Text Challenge Post by: ChatKing on October 13, 2012, 03:38:10 pm Hi Friends
Can anybody write qbasic code for the following challenge. A program where we enter a complete sentence and then program display each word singly on a separate lines. Let me explain Console ask for the a complete sentence, let suppose use input. We are humans and the program display it like this We are humans I am waiting for the replies and your code. When I get your code, then I will share with you mine code. Thanks Title: Re: New Text Challenge Post by: GarrisonRicketson on October 24, 2012, 12:10:55 pm I had something like this, somewhere , Sorry to be slow on the reply. If I can remember, or find the code I had for this, I'll post it
from Garry Title: Re: New Text Challenge Post by: SMcNeill on November 24, 2012, 12:17:45 am An easy solution to this one:
Code: DIM sentence AS STRING, word AS STRING PRINT "Give me a sentence: "; INPUT sentence sentence = sentence + " " DO wordpos = INSTR(sentence, " ") word = LEFT$(sentence, wordpos - 1) sentence = RIGHT$(sentence, LEN(sentence) - wordpos) PRINT word LOOP UNTIL wordpos = 0 Title: Re: New Text Challenge Post by: GarrisonRicketson on November 24, 2012, 08:20:50 am Thanks SMcNeill I tried it and it works good. Thanks for stopping by and posting this. from Garry |