QBasic problem , simple output program

  • Thread starter Thread starter 1/2"
  • Start date Start date
  • Tags Tags
    Output Program
Click For Summary

Discussion Overview

The discussion revolves around a QBasic programming problem related to output formatting using loops. Participants are exploring how to accept a word and print it in a specific visual format, particularly focusing on using basic string manipulation functions and loops without delving into more complex programming techniques.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant seeks help with a QBasic output problem involving loops and string manipulation, specifically asking for guidance on formatting output without using complex functions.
  • Another participant requests to see the original code to provide more tailored assistance.
  • A suggestion is made to use the "locate" function for positioning output on the screen.
  • A proposed solution includes a loop that prints increasing lengths of the input string, demonstrating a basic approach to the problem.
  • Concerns are raised about how to handle spaces in front of the output to achieve the desired visual effect.
  • Participants emphasize the importance of showing some work in the homework section and suggest using spaces to align the output correctly, along with a method to create a "V" shape in the output.
  • A method is proposed to create a string of spaces to facilitate the formatting of the output, suggesting the use of the LEFT$ command to manage spacing effectively.

Areas of Agreement / Disagreement

Participants generally agree on the need to show some work in the homework context and share various approaches to formatting the output. However, there is no consensus on the best method to achieve the desired output shape, as multiple suggestions are presented.

Contextual Notes

Participants have not fully resolved the specific implementation details regarding the spacing and alignment of the output, and there are varying suggestions on how to achieve the visual format requested.

1/2"
Messages
98
Reaction score
0
Does anyone know QBasic here? (cuz it is very uncommon)
Here I have got simple output problem using loop.
How do I accept a word(any) and print it like this(attached)

We can use Nested loop,Left$ ,Right$ MID$,and blanks( please don't go into more complex functions because I haven't learn't it yet)
I one the first part all well till" L" but it becomes messy after this!
PLz help!
 

Attachments

Physics news on Phys.org
Show us your code. There are probably quite a few of us here with experience in QBasic.
 
You can use the "locate" function.
 
You might like to try something like this:

INPUT a$
L = LEN(a$)
FOR I = 1 TO L
PRINT LEFT$(a$, I)
NEXT

This produces an increasing number of characters of whatever you feed in as the input.

Since this is in the homework section, you can easily work out from there how to put it in the form you asked for.
 
What about the blanks in front?
 
This is the homework section, so you need to show some work yourself.

You would put spaces at the beginning of the line so that the total number of characters was equal to the length of the input line. Then you have progressively more spaces and less characters.
Then do the reverse to get the "V" shape.

To print a space, you print " ";
Note the semicolon to avoid starting a new line.

A better way would be to set up a string like this:
space$ = "___________________ " (ignore the underlining)
and take spaces from it with the left$ command.
Then print these before the left$ part of the input string.
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K