answersLogoWhite

0


Best Answer

It's been a long time since I've written any BASIC.

There are a few ways this could be done. This way creates a table (array) with the values, then prints the table:

10 DIM A(10)

15 FOR X=1 TO 10

20 A(X)=2*X

25 NEXT

30 FOR X=1 TO 10

35 PRINT A(X); ", ";

40 NEXT

45 END

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you print 2 4 8 up to 20 in qbasic?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Art & Architecture

What is the value of a sister corita print?

email the Corita Art Center staff, with the name of the print or if the print is unmounted you will find a set of numbers on the low left corner of the print. 2 first numbers is the year of the print, second set is the number of the print been printed that year.


How much is a colin paynton print worth?

2 million


Eduardo reduced the size of a painting to a height of 2 in what is the new width if it was originally 10 in wide and 20 in tall?

This question is not about painting, it's about math. It is a proportion problem: 2 is to 20 as "X" is to 10. Cross multiplication yields the equation 2*10 = X*20, which gives the answer X = 1.For what it's worth, Eduardo is ending up with a pretty small painting...


What are 2 ways in making a photographic print?

1. Contact - in which the negative is sandwiched with the print paper and exposed to light, then the print developed2. enlargement - in which the negative is projected and focused on the paper to be exposed, which is then developed as above.Contact prints are suitable for a "quick look" such as to pick which pictures to "enlarge".You have to do so because most people cannot tell what a picture looks like from its negative.


How much is the painting with the hiding Siamese cat worth by gene pelham?

Between $100 and $200 if it's the actual oil painting. If it's a print, then not much. I have the large framed print myself. It measures (with black and green wood frame) 37 1/2 " x 40 1/2" . Got mine for free on Craigslist.

Related questions

What is the function key to execute Qbasic program?

QBASIC operators are listed as follows.../along with some example QBASIC code... ->LOGICAL OPERATORS AND OR NOT EXAMPLE QBASIC CODE:- A=1 B=1 IF (A AND B) THEN PRINT "Result: True" ELSE PRINT "Result: False" ...output... Result: True A=1 B=2 IF (A AND B) THEN PRINT "Result: True" ELSE PRINT "Result: False" ...output... Result: False -> MATHEMATICAL OPERATORS + plus - minus * multiply / divide MOD division remainder ^ raise to the power EXAMPLE QBASIC CODE:- num1=4 num2=2 PRINT num1 + num2 PRINT num1 - num2 PRINT num1 * num2 PRINT num1 / num2 PRINT num1 MOD num2 PRINT num1 ^ num2 ...output... 6 2 8 2 0 16 -> COMPARISON OPERATORS = equals > greater than < lesser than >= greater than/or, equals <= lesser than/or, equals <> not EXAMPLE QBASIC CODE:- num1 = 6 num2 = 8 IF num1 = num2 THEN PRINT "Equal to" IF num1 > num2 THEN PRINT "Greater than" IF num1 < num2 THEN PRINT "Lesser than" IF num1 >= num2 THEN PRINT "Greater than/or, equal to" IF num1 <= num2 THEN PRINT "Lesser than/or, equal to" IF num1 <> num2 THEN PRINT "NOT equal" ...output... Lesser than Lesser than/or, equal to NOT equal


How do you print the first 20 even numbers in qbasic?

startNum% = 0 endNum% = 38 counter% = 1 PRINT "Counter", "Number" PRINT FOR num% = startNum% TO endNum% STEP 2 PRINT counter%, num% counter% = counter% + 1 NEXT *NOTE*: This prints out all of the even numbers starting from 0 up to 38; if you didn't wish 0 to be included as well; then, change it to say... startNum% = 2 endNum%= 40


Relational operator string vs numarical?

QBASIC relational operators are... = equal > greater than < lesser than >=greater than/OR, equal to <=lesser than/OR, equal to EXAMPLE QBASIC CODE:- IF 1 > 2 THEN PRINT "1 greater than 2" IF 1 < 2 THEN PRINT "1 lesser than 2" IF 1 = 2 THEN PRINT "1 equal to 2" IF 1 >= 2 THEN PRINT "1 greater than/OR, equal to 2" IF 1 <= 2 THEN PRINT "1 lesser than/OR, equal to 2" ...Output... 1 lesser than 2 1 lesser than/OR, equal to 2 Press any key to continue... QBASIC mathematical operators are... + plus - minus / divide * multiply MOD modulus (remainder) ^ raise to the power EXAMPLE QBASIC CODE:- PRINT "3 + 3 = "; 3 + 3 PRINT "3 - 3 = "; 3 - 3 PRINT "3 / 3 = "; 3 / 3 PRINT "3 * 3 = "; 3 * 3 PRINT "3 MOD 3 = "; 3 MOD 3 PRINT "3 ^ 3 = "; 3 ^ 3 ...Output... 6 0 1 9 0 27 Press any key to continue...


How do you add odd numbers only in qbasic from 1 to 10?

CLS FOR eachNum%=1 TO 10 STEP 2 PRINT eachNum% NEXT


Write a qbasic program to print the squares and cubes of first 10 natural numbers?

10 CLS 20 FOR n = 1 to 10 30 PRINT n, n^2, n^3 40 NEXT n 50 PRINT: PRINT: PRINT "Touch 'x' to go again, any other key to end." 60 INPUT a$ 70 IF a$ = "X" or a$ = "x" THEN 10 80 END


Find the power of a positive integer in qbasic?

PROGRAMMING LANGUAGE: QBASIC/VERSION: QB64 ...Program code... intNum% = 2 CLS PRINT "PROGRAM: POWERS OF N/(N ="; intNum%; ")" PRINT FOR intEachLoopNum% = 0 TO 10 PRINT intNum%; " ^ "; intEachLoopNum%; " = "; intNum% ^ intEachLoopNum% NEXT ...Output... 2 ^ 0 = 1 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024 *NOTE*: In QBASIC the mathematical symbol: ^...means 'raise to the power of'; thus, 2 ^ 3; actually means raise the number 2 to the power of 3/or, 2 x 2 x 2.


What is the program in QBASIC to print the following series 1 4 9 16?

10 CLS: PRINT "I shall now amaze the audience by printing " 20 PRINT "the four smallest perfect square integers." 30 for N = 1 to 4 : PRINT N, N^2 : NEXT N 40 PRINT: PRINT "Thank you." 50 PRINT "You've been a wonderful audience." 60 PRINT "I'm here until Friday." 70 PRINT "Don't forget to tip your waiter."


What is the code to print odd numbers from 20 to 30 in qbasic?

The following code will produce a list of numbers in steps of 2. It can be modified for any start & end number, and the size of the step. start% = 21 end% = 29 FOR num% = start% TO end% STEP 2 PRINT num% NEXT The above code will produce the results 21,23,25,27 & 29


How do you write a program in QBASIC to print the names of any 5 laptop companies?

EXAMPLE 1 - LANGUAGE: QBASIC '*** printing string literals... CLS PRINT "Laptop manufacturers:-" PRINT PRINT "Toshiba" PRINT "Sony" PRINT "Apple" PRINT "Dell" PRINT "Samsung" END EXAMPLE 2 - LANGUAGE: QBASIC '*** printing string values from an array name variable... DIM companyName$(5) companyName$(1) = "Toshiba" companyName$(2) = "Sony" companyName$(3) = "Apple" companyName$(4) = "Dell" companyName$(5) = "Samsung" CLS PRINT "Laptop manufacturers:-" PRINT FOR eachCompanyNo% = 1 TO 5 PRINT companyName$(eachCompanyNo%) NEXT END EXAMPLE 3 - LANGUAGE: QBASIC '*** READing/and, PRINTing from DATA statements list... CLS PRINT "Laptop manufacturers:-" PRINT READ eachCompanyName$ DO WHILE eachCompanyName$<>"EOF" PRINT eachCompanyName$ READ eachCompanyName$ LOOP END DATA "Toshiba","Sony","Apple","Dell","Samsung" DATA "EOF" *NOTE*: There are many more ways that it's possible to do this, too. Including... -Storing data in an external text based file(.txt/.dat/.csv); then, opening/reading in/printing values from that external data file/closing the file. -using fixed length strings/together with dot notation -etc. I will leave it up to you to go and discover how to use such further possibilities; and, more... CONCLUSION As you can see from the above code examples/suggestions; QBASIC, is a very highly versatile programming language; which, quite often, gives programmers multiple different ways to write their underlying 'source code'...though, each differently written program will produce exactly the same surface 'output'.


What does the QBASIC automatically capitalize for you?

EXAMPLE 1 The QBASIC program will, automatically, *capitalize* any reserved 'keyword' which it finds once you've already gone and typed in a line of code; and, then, at the end of that code line, do finally press the [RETURN/ENTER] key...to confirm what you've just gone and typed in. A keyword might be say the PRINT command statement...so, if I were to type inside of the QBASIC editor the following line of code... print 1+1 ...then, the moment I press the [RETURN/ENTER] key when I get to the end of that line...the QBASIC interpreter program will, automatically, change the 'lower case' word: print...to become all UPPERCASE, instead; QBASIC Editor will display the previous line of code I typed in as being... PRINT 1+1 ...thus, I am able to tell immediately that PRINT is a special reserved 'keyword'/or, command statement which the QBASIC program, quite clearly, recognizes and understands. This also helps me the programmer to know if I actually typed in that 'keyword' either correctly/or, incorrectly; if wrong...and, the program did NOT automatically capitalize it...; then, I know I must have either accidentally 'misspelled' the keyword/or, must otherwise have done something to go get it wrong...?! EXAMPLE 2 If I were to type in to the QBASIC Editor program the following line of code using all 'lower case' letters... x=10: if x=10 then print "ten" else print "NOT ten" ...and, then, when I've reached the end of that line of code, press [RETURN/ENTER] key to confirm my code entry; the QBASIC interpreter program will, automatically, respond by capitalizing any reseved 'keywords' that it finds; then, QBASIC Editor displays the line of code I typed in as being... x=10 : IF x=10 THEN PRINT "ten" ELSE PRINT "NOT ten" Looking at this newly capitalized line...it tells me that... IF/THEN/ELSE/PRINT...are all QBASIC reserved 'keywords'. NOTE: Whatever is a string a text that is written in between double quote marks: ("") will be totally unaffected by such capitalizing; instead, text strings will be printed out, quite literally, 'as is'. FINAL NOTE There are far too many QBASIC 'keywords' for me to go and list here; possibly, a couple hundred...! QBASIC has many 'keywords' that it uses; if you wish to see what ALL of these keywords are; then, from inside of the QBASIC Editor program itself...do a combination key press of: [SHIFT] + [F1]...and, there you will see the Help file...that shows each 'keyword' you can use to write QBASIC programs with; as well as, offering a clear explanation/it shows 'example codes' demonstrating exactly how each of these 'keywords' should be used; just do 'copy & paste'/then, RUN the program to follow these examples along.


When you add the even and odd numbers from 1 to 20?

Upon adding the even and odd numbers from 1 to 20, you should arrive at the sum of 210. ===== ...QBASIC program... sumTotal% = 0 CLS PRINT "PROGRAM: Add numbers 1 to 20" PRINT PRINT "Number", "Total" PRINT FOR eachLoopNo% = 1 TO 20 PRINT eachLoopNo%, sumTotal% = sumTotal% + eachLoopNo% PRINT sumTotal% NEXT PRINT "Sum total ="; sumTotal% ...Output... PROGRAM: Add numbers 1 to 20 Number Total 1 1 2 3 3 6 4 10 5 15 6 21 7 28 8 36 9 45 10 55 11 66 12 78 13 91 14 105 15 120 16 136 17 153 18 171 19 190 20 210 Sum total = 210 Press any key to continue...


How do you check a prime number in qbasic?

Cls input "enter the no. You want to check", a if a <=0 then print "only natural nos allowed" if a <=0 end let m = a - 1 for i = m to 2 step -1 if a mod i = 0 then print "not prime" if a mod i = 0 then end next i print "prime" end