answersLogoWhite

0

QBasic

QBasic is an integrated development environment (IDE) and interpreter for a variant of the BASIC programming language. QBasic includes a debugger with code modification and on-the-fly expression evaluation that can run under most versions of DOS, Windows, Linux and FreeBSD.

221 Questions

How i will write a program in qbasic -to display your name multiple times using do whileloop?

QBASIC code/Editor Screen

(Press key [F5] to make the program RUN/execute...)

====

(Pressing any key returns you straight back to the Editor screen; where you can either chose to further Edit/Re-Run/or else, Save your program.)

Here is another example.

CLS

COLOR 15, 4, 14

PRINT "Press any key to continue"

DO WHILE INKEY$ = ""

LOOP

FOR c = 1 TO 20

COLOR c, 0

PRINT "Replace this with the name you want to display"

NEXT c

COLOR 15, 0

END

How do make 10student name and his remarks in q-basic?

'

'*** PROGRAM: Collecting student data: names/marks.

'

'*** Create 2 array variables to store each students name/marks...

DIM students$(10), marks$(10)

'*** SCREEN ONE/Collect the data...

CLS '...(CL)ear the Output (S)creen

'*** print heading...

PRINT "PROGRAM: Collecting each student names/marks..."

PRINT

'*** A FOR/NEXT loop is used to collect each individual students data...

FOR eachStudentNo% = 1 TO 10

'*** Get each students names/marks

'by typing these values in from the keyboard....

PRINT eachStudentNo%; ">"

INPUT " Enter student name"; students$(eachStudentNo%)

INPUT "Enter student marks"; marks$(eachStudentNo%)

NEXT

'*** SCREEN TWO: Output the collected data...

CLS '...(CL)ear the Output (S)creen

'*** Print headings...

PRINT "Student No.", "Student Name", "Student Marks"

PRINT

'*** FOR/NEXT loop is used to print out the 2 array student 'name/marks' values...

FOR eachStudentNo% = 1 TO 10

'*** print out each students 'number/name/mark' values...

PRINT eachStudentNo%,

PRINT students$(eachStudentNo%),

PRINT marks$(eachStudentNo%)

NEXT

END '...END of program/halt program code execution

What is a sub programs in qbasic?

Sub programs allow you to break up one long program; into being a series of much smaller tasks; usually, controlled by a main program. Example...

====

As you can see from the above 2 examples; the 2nd example, although longer, creates code that is much clearer and simpler to read. Even non-programmers should be able to figure out what the 'Main Program' section is doing.

NOTE: There are certain rules for the use of sub-routines. Such as the sub routine should confine itself to doing just 'one' task at a time. So, SUB clearScreen...does just 'one' job, alone...which is to (CL)ear the output (S)creen. It does NOT clear the screen AND get the user to input a number. This makes it quicker and easier to debug programs; as you know exactly where the code is going wrong; so, for example, if the screen didn't clear, properly...then, look at the Sub-routine called: SUB clearScreen. If the title didn't appear; then, look at the Sub-routine called: SUB printTitle. /-Etc.

How do you prepare a program in basic to display the word and the number of letters in it when is given as input?

10 cls

20 input"enter word";word$

30 print word$

40 print len(word$)

50 end

this program is for GW BASIC for other BASIC's the line numbers are optional.