Weekly Qbasic and Qb64 Lesson Topics
October 12, 2024, 05:05:36 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

New Text Challenge

Pages: [1]
  Print  
Author Topic: New Text Challenge  (Read 1879 times)
ChatKing
Post Demos
*
Posts: 23


« 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
Report Spam   Logged

Share on Facebook Share on Twitter

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 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
Report Spam   Logged

SMcNeill
Newbie
*
Posts: 3


« Reply #2 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
« Last Edit: November 24, 2012, 12:20:07 am by SMcNeill » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 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
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy