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.

500 Questions

To print 5 45 345 2345 12345 in qbasic programming?

User Avatar

Asked by Wiki User

5

45

345

2345

12345

How do you write a magic square program with basic?

User Avatar

Asked by Wiki User

Answer

You're better off using a program like Visual Basic or C++ to do that. QBasic doesn't have very many capabilities.


AnswerQBasic is quite capable. It is certainly capable of solving a magic squares problem.

How do you make binary to decimal converter in G W BASIC?

User Avatar

Asked by Wiki User

First of all we will talk about how binary number are converted back into decimal representation and later we will have program.

Here is the formula of this transformation:

Binary number: a3a2a1a0

Decimal number a x 23 + a x 22 + a x 21 + a x 20

Example:

Binary: 1101

Decimal: 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 8 + 4 + 0 + 1 = 13

And here we have our program:

#include

#include

#include

int main() {

char str[100];

int ind;

int sum = 0;

printf("Please enter binary number: ");

scanf("%s", str);

for(ind = 0; ind < strlen(str); ind++) {

sum += (str[ind] - 0x30) * pow(2, strlen(str) - ind - 1);

}

printf("Number in decimal would be %d\n", sum);

return 0;

}

Testing:

Please enter binary number: 1101

Number in decimal would be 13

Please enter binary number: 10000001

Number in decimal would be 129

Please enter binary number: 11111111

Number in decimal would be 255

Please enter binary number: 0

Number in decimal would be 0

What is the default screen mode of Qbasic?

User Avatar

Asked by Wiki User

The default screen mode for Qbasic is 0.

What basic programming languages did Bill Gates develop?

User Avatar

Asked by Wiki User

No. BASIC was the brainchild of John G. Kemeny and Thomas E. Kurtz in 1964. Bill Gates' contribution, along with Paul Allen, was to develop a BASIC interpreter for the MITS Altair 8800 in 1975.

What are the design principles in BASIC programming language?

User Avatar

Asked by Wiki User

4.1 Design Tradeoffs

Conceptual design involves a series of tradeoff decisions among significant parameters - such as operating speeds, memory size, power, and I/O bandwidth - to obtain a compromise design which best meets the performance requirements. Both the uncertainty in these requirements and the important tradeoff factors should be ascertained. Those factors which can be used to evaluate the design tradeoffs (usually on a qualitative basis) include:

  • Reliability
  • Expandability
  • Programmability
  • Maintainability
  • Compatibility
  • Adaptability
  • Availability
  • Development Status and Cost

Recommended practices for achieving reliability are given in section 4.5. The remainder of these features are discussed below.

Expandability measures the computer system's ability to conveniently accommodate increased requirements by higher speed or by physical expansion, without the cost of a major redesign (ref. 84). The original design of the computer should provide for this type of growth, especially with regard to the memory and I/O sections. The general procedure is to determine all the functions that foreseeably could be demanded of the computer system, such as by reviewing growth problems of past programs, and to establish a range of possible requirements for each of the functions, which may double the present requirement. If possible, the likelihood of these expanded requirements should also be estimated. Modularity is a desirable method for providing expandability and should be incorporated whenever feasible.

Prorgrammability, or the ease of programming the computer, should be considered early in the design. Past experience has shown that a balance between programming simplicity and hardware complexity is essential to prevent the costs of programming from becoming overwhelming. For example, sufficient memory capacity should be provided to accommodate program changes necessitated by increased performance or mission requirements; memory architecture should be designed to facilitate programming; and hard-wired memories should be avoided if many program changes are anticipated, because of the time and cost involved in implementing the changes. Adequate addressing facilities without artificial boundaries and a simple subroutine linkage are recommended. Considerations of programmability should include the efficiency of the source language, of the object code, and of converting from the source language to the object code, and the ease of using the source language and obtaining a completely coded computer program. If the computer is to be programmed in flight, the use of a compiler should be considered. A standard programming language, such as JOVIAL, SPL, or CLASP, is desirable and should be utilized for future applications if available. The degree of software sophistication and the availability of support software should be considered during the design.

Maintainability should not be neglected when designing the computer. Repair should be readily accomplished during ground operation, and if inflight maintenance is desired, this should be specified as a design requirement. Inflight repair or reconfiguration is closely associated with reliability and, as such, the extent of reconfiguration made possible will be dependent upon the reliability required. Malfunctions can often be detected by self-check programs; inflight repair can be effected by automatic switching, or by manual operation on manned missions. The tradeoff should consider the use of a degraded mode of operation. Generally, the recommended prelaunch maintenance procedure is to remove bad components or subsystems from the system and replace them with backup equipment. To facilitate manual maintenance, subassemblies should be pluggable, require a minimum of disassembly for access, and be replaceable without adjustment. The design should provide case of accessibility and should minimize the possibility of damage to other parts during maintenance. If replaced assemblies are to be discarded rather than repaired, maximum cost goals for a replaceable module should be established.

Compatibility should be developed between the computer and its interfaces, software, power levels, and, where necessary, ground computers. Standard interfaces and power levels should be implemented. Interface compatibility reduces the need for data conversion with peripheral equipment and is highly recommended. Data compatibility between models of a computer family should be provided to simplify the design of peripheral equipment. This consideration is particularly important when computers of different performance and architecture are interconnected. Source and object code compatibility between the spaceborne and ground-based computers is advantageous to facilitate programming.

Adaptability is defined as the ability of the system to meet a wide range of functional requirements without requiring physical modification. Adaptability is needed when requirements are not well defined or if it is anticipated that the computer will be applied to a variety of missions and/or a number of space vehicles. Although this is similar to the need for growth discussed under "expendability," in this case, potential requirements should be anticipated by providing reserves in memory capacity, computational speed, word length, and I/O capability. Moreover, the design should consider specific features which allow tailoring a basic machine to different situations, such as an adjustable word length through byte organized operations, alterable or unused operation codes, reserved fields within formats, and adjustable speed. Caution must be taken that the increase in computer capabilities is in accordance with other development considerations.

Availability is the probability that the computer is operating satisfactorily at a given time. It is closely related to reliability and repair time and should be considered in establishing reliability requirements. Since it takes into account the time required for malfunction detection and reconfiguration or repair, availability is particularly important during time-critical mission phases.

Development Status and Cost are complex management-related factors which can have significant effects on the design. They require the estimation of a number of items such as the extent of off-the-shelf hardware use, design risks in developing new equipment using advanced technologies, potential progress in the state of the art during the design and development of the computer, etc. In estimating cost, the manager should consider the total long-range expenditures as well as initial outlays, and also the cost of potential delays in developing advanced techniques, etc.

In addition to the above qualitative factors, tradeoffs should be determined on the basis of specified quantitative factors, such as precision, speed, capacity, weight, volume, and power.

Write a program in qbasic to make a hut using print statemant?

User Avatar

Asked by Wiki User

a triangle then a square :)

Explain the if-then-else statement with syntax in computer QBASIC?

User Avatar

Asked by Wiki User

Here is a simple example of a program using the IF...THEN...ELSE... statement in QBASIC:

1 CLS

2 INPUT "What is your name?" NAME$

3 IF NAME$ = "Fred" THEN GOTO 4 ELSE GOTO 6

4 PRINT "Fred is a cool name!"

5 END

6 PRINT "Your name isn't Fred, you're Lame!"

7 END

NB: My name isn't Fred!!!

How the statement works is simple...

IF [VARIABLE NAME] [EQUALS/DOES NOT EQUAL/GREATER THAN/LESS THAN] [PERAMETER] THEN [ACTION] [PERAMETER] ELSE [ACTION] [PERAMETER]

A similar function exists in most programming languages, and uses can range from a simple calculation to password control. Also, you can use other commands within this (eg: OR) or use several commands together to give more options:

1 CLS

2 INPUT "What is your name?" NAME$

3 IF NAME$ = "Fred" THEN GOTO 4 ELSE GOTO 6

4 PRINT "Fred is a cool name!"

5 END

6 IF NAME$ = "Bob" THEN GOTO 7 ELSE GOTO 9

7 PRINT "Fred is a cool name, but Bob is OK too!"

8 END

9 PRINT "Fred is OK, Bob is Acceptable but "; NAME$; " is just lame!"

10 END

NB: Bob is not my name either, guess I'm lame!

Hope this answers your query!

Dan

PS: Other statements used in examples:

CLS = Clear Last Screen

INPUT = Allows you to enter data after text is displayed, and attach to the variable

PRINT = Print the text.

END = Finish the program run.

It may also be useful to note, if using QBASIC on Windows Vista the LPRINT function does not work correctly. If you need to output to a printer, it is better to save as a text file and then print within the Windows Vista environment. Alternatively, run an older version of Windows just for programming in. I tend to use Windows 2000 professional - good flexability and pretty stable!

=====

No disrespect meant to the above programmer; who, overall, I think, has done a really fine job of explaining things. ;-)

Nevertheless, for me, the above code contains certain problems which still need to be addressed and fixed...

A) Line number 2...

2 INPUT "What is your name?" NAME$

...is incorrect syntax...instead, it should have said...

2 INPUT "What is your name?";NAME$

...including a semi-colon symbol(;) which is to be placed in between both quoted text("")/and, variable name(NAME$).

B) The first example uses the END statement, twice; and, the second example uses the END statement three times, no less...; but, strictly speaking, there should only be no more than just 'one' single END statement, alone, in any program.

C) The use of LINE NUMBERS together with GOTO statements is completely outdated...and, quite often, can lead to difficult to read, error prone programs; these are ancient relics belonging to the old time 'original' BASIC programming language.

When using the modern day QBASIC programming language we don't need to rely on using such old fashioned statements anymore...much preferring instead to use carefully structured block statements...which makes our program logic read a lot more clear.

I would re-write program 1, by using an IF-THEN-ELSE-END IF statement block, as...

CLS

INPUT "What is your name?";name$

IF name$ = "Fred" THEN

PRINT "Fred is a cool name!"

ELSE

PRINT "Your name isn't Fred, you're Lame!"

END IF

END

I would re-write program 2, by using an IF-THEN-ELSEIF-ELSE-END IF statement block, as...

CLS

INPUT "What is your name?"; name$

IF name$ = "Fred" THEN

PRINT "Fred is a cool name!"

ELSEIF name$ = "Bob" THEN

PRINT "Fred is a cool name, but Bob is OK too!"

ELSE

PRINT "Fred is OK, Bob is Acceptable but "; name$; " is just lame!"

END IF

END

NOTE: In the above amended code; there are no line numbers/and, no goto's.

NOTE: Each of the above programs has 'one'...and, only 'one' single END statement.

NOTE: My own variable names begin by using all lower case letters; and, I will capitalise each 1st letter of any successive word(s) appearing in the same variable name...nameOne$/nameTwo$/nameThirtyThree$...as it makes the code read a lot more clear...when it comes to very quickly and easily distinguishing between what is a QBASIC language keyword such as PRINT/and, what is a variable name which was invented by the actual program writer themselves.

Everybody tends to write code differently; so, if 100 different programmers were asked to write a program which displays exactly the same 'surface output'; then, one would most likely find that the underlying 'source code' beneath has been written entirely differently by every single programmer!

Programming 'style'...is really all down to a matter of personal taste/or, choice. You will learn this as you come across reading more and more programs. For example, going back to the question of what type of variable name to use? Some people like using the minimal, n$/others use all capitals NAME$/and, yet, another writes it as being all lower case, name$/whereas, a next programmer might write it using long form, 3 letter prefix, strName$/-etc. Furthermore, some will add code comments/and, other's don't! Over time, and, with experience we all tend to develop our own much preferred style of writing programs; going according to whichever method we find works best, and, does most tend to suit our own personal needs.

NOTE: The IF statement comes in quite a few different forms...

(single line)

A) IF/THEN

B) IF/THEN/ELSE

(multiple lines; also, called a statement block)

C) IF/THEN/ELSE/END IF

D) IF/THEN/ELSEIF/ELSE/END IF

...which I will quickly illustrate as...

A)

x=1

IF x=1 THEN PRINT "one"

B)

x=3

IF x=1 THEN PRINT "one" ELSE PRINT "NOT one"

C)

x=2

IF x=1 THEN

PRINT "one"

ELSE

PRINT "NOT one"

END IF

D)

x=1 : y=2

IF x=1 THEN

PRINT "one"

ELSEIF x=2 THEN

PRINT "two"

ELSE

PRINT "NOT one/NOT two"

END IF

How to convert Qbasic to C?

User Avatar

Asked by Cman42

10 REM Sample BASIC Program - Counts To Ten 20 REM 30 REM Copyright 2005 Andrew Eichstaedt 40 REM Eichstaedt Development Group 50 REM http://www.andrew-eichstaedt.com 60 REM 70 PRINT "Hello! I am a sample BASIC program" 80 PRINT "that counts to ten." 90 PRINT 100 FOR I=1 TO 10 110 PRINT I 120 NEXT I 130 PRINT 140 PRINT "Thanks for running me." 150 END

How do you write a programme in basic to assign a number and print its square?

User Avatar

Asked by Wiki User

num%=9

CLS

PRINT "The square of: "; num%; " = "; num%*num%

END

What is the extension of qbasic program?

User Avatar

Asked by Wiki User

.bas file

====

<--QBASIC CODE end

Now, go and search your computer c:\ directory for the file called: homepage.htm; and, left double click on it to run; your web browser software should automatically launch itself, and, so display the web page output. Right click within an empty space within the web browser page...and, choose View > Source...and, you will be able to see the HTML source codes which were used to originally write the web page with; though, the QBASIC code itself is not displayed but remains entirely hidden.

How do you write vowels in Qbasic?

User Avatar

Asked by Wiki User

cls
input" enter any string";a$
f=Len(A$)
d=1
AA:
b$= mid$(a$,d,1)
d=d+1
c=asc(b$)
if c=101 or c=105 or c=970 or c=111 or c=117 then
cnt= cnt+1
end if
if d<=f then goto aa
print cnt;
end

How would you write a program to display even numbers between 0-20?

User Avatar

Asked by Wiki User

ALGORITHM EVEN

BEGIN

FOR ( num = 0; num <= 20; num++ )

BEGIN

IF ( num MOD 2 == 0 ) THEN

DISPLAY (num)

END IF

END FOR

END EVEN

in C:

#include <stdio.h>

int main (void) { puts ("0 2 4 6 8 10 12 14 16 18 20"); return 0; }

What is a linear queue?

User Avatar

Asked by Wiki User

A linear queue models the FIFO(first in first out) data structure, much like a line in real life. The first person in line will be the first person served, in queues the first element to be added is the first that can be removed. The only adding point is to the end of the list and the only removal point is the beginning of the list.

Queue<String> q = new LinkedList<String>(); // The LinkedList class implements Queue

q.add("Bob"); // Now Bob is at the front of the queue

q.add("Stacy"); // Stacy after Bob

q.add("Will"); // and Will after her

String removed = q.remove(); // Bob is removed

q.add("Michael"); Michael is added after Will

System.out.println(q); // Prints ["Stacy", "Will", "Michael"]

What are control structures used in javascript?

User Avatar

Asked by Wiki User

The control structures used in java script are if-statement, for-loop, for-in loop, while loop,do-while loop, switch-statement, with-statement. try-catch-finally statements.

What is the difference between photo electric effect and compton effect?

User Avatar

Asked by Wiki User

  • The photo-electric effect causes a current to pass between two plates that already have a voltaic potential difference.
  • the photovoltaic effect causes a voltage to grow between two plates that don't already have one (or changes the applied voltage to something else). There is no current.

In photo electric effect,

  • When light(photon) Strikes on the one plate,electron in outershell of atom is ejected by absorbing the light.And electron can move from its plate to other plate if energy of photon is satisfy the break force of surface into electron and potential energy of two plates.So current is generated.

In photo voltaic effect,

  • When light(photon) Strikes on the one plate, electron in outershell of atom is go up to new energy level by absorbing the light. So no charge carriers move.Therefore no current.

Examples of high level programming languages?

User Avatar

Asked by Wiki User

  • Java
  • C
  • Python
  • Scheme
  • Prolog
  • C++
  • C#
  • Java script
  • Lisp
  • Ruby

How do you add 2 numbers in QBASIC?

User Avatar

Asked by Wiki User

I'm not too sure that I understand exactly what you mean by 'add a square'...?! Thus, I will attempt to answer the question using multiple different ways; hoping that, least, 'one' of these answers might be right...

==>

CLS

PRINT "PROGRAM: Twelve Times Tables Number Square"

PRINT

FOR intTimes% = 1 TO 12

FOR intTables% = 1 TO 12

sum% = intTimes% * intTables%

noOfSpaces% = 0

IF LEN(STR$(sum%)) = 2 THEN noOfSpaces% = 2

IF LEN(STR$(sum%)) = 3 THEN noOfSpaces% = 1

PRINT sum%; SPC(noOfSpaces%);

NEXT

PRINT

NEXT

END

<==

...QBASIC Code/End.

How do you swap two numbers in qbasic?

User Avatar

Asked by Wiki User

Create a form with two text boxes (txtNumber1, and txtNumber2) and a command button (cmdSwap).

Option Explicit

Dim numb1 As Variant

Dim numb2 As Variant

Private Sub cmdSwap_Click()

numb1 = txtNumber1.Text

numb2 = txtNumber2.Text

txtNumber2.Text = numb1

txtNumber1.Text = numb2

End Sub

Why qbasic is a higher level languages?

User Avatar

Asked by Wiki User

QBasic Benefits :-

1) It is a good language for beginners.

2) It has English-like commands.

3) QBasic has an easy format and is easy to implement.

4) The errors in codes can be fixed easily.

QBasic Limitations:-

1) It is not professional programing language.

2) The language is not structured.

3) It is hard to understand.

4) It is rarely used in real life except in the field of education and training.

How do you display 1 11 111 1111 11111 in qbasic using FOR.NEXT?

User Avatar

Asked by Wiki User

cls

a =1

for i = 1 to 5

print a;

a = (a*10)+1

next i

end

What are the words that make up a high-level programming language called?

User Avatar

Asked by Wiki User

Some languages have specific terms, however keyword or reserved word is the general terminology we use when referring to a programming language's primary vocabulary. That is; words that cannot be used as identifiers. However, some languages also have contextual keywords. For instance, C++ has final and override contextual keywords. These can be used as both identifiers and keywords, depending on the context. The only reason for this is that people were using these words as identifiers before they were introduced to the language (in C++11) and making them actual keywords would have broken a lot of older code.

How do you print kamal kama kam ka k this pattern in qbasic?

User Avatar

Asked by Wiki User

Cls

Dim n as string

Dim b as string

b="Kamal"

For a=5 to 1 step -1

n=left$(b, a)

Print n

Next a

End