Write a program to print an natural number in QBasic statements ? Using FOR LOOP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program to print an natural number in QBasic statements ? Using FOR LOOP

30th Jan 2021, 4:20 AM
Shankar Verma
Shankar Verma - avatar
9 Answers
+ 3
RKK Yes you're right I didn't notice it...I was also having Qbasic in my syllabus but not so advanced till for loops
30th Jan 2021, 5:37 AM
∆BH∆Y
∆BH∆Y - avatar
+ 3
OK, give details of the question...your question is not clear or ask your computer teacher 😃
30th Jan 2021, 5:42 AM
∆BH∆Y
∆BH∆Y - avatar
+ 2
I have 2 questions 1. Why are you learning BASIC? Last time I checked (around 5 years ago), I couldn't even find an interpreter for it. I don't see any real point in learning BASIC now (Disclaimer: I might be wrong here and I'd love to be corrected) 2. Why would you need a for-loop to print a single number? for-loops are used when you need to operate on a series of numbers Anyways, this is the only resource I found which covers the whole language. There is a section for for-loops in it, you can check that out https://upload.wikimedia.org/wikipedia/commons/6/6c/QBasic_v1.2.pdf
30th Jan 2021, 4:32 AM
XXX
XXX - avatar
+ 2
XXX ∆BH∆Y Seeing the tags "6th" and "class" in his question I guess that Qbasic is included in their syllabus so.
30th Jan 2021, 5:35 AM
Rohit
+ 2
Shankar Verma search on google once
30th Jan 2021, 5:39 AM
∆BH∆Y
∆BH∆Y - avatar
+ 2
RKK oh right! Even I had that! Shankar Verma first of all, read my second point again. I don't see any reason of using a for loop to print a single natural number. Kindly read your question again. It may be that you were being asked to print the first n natural numbers or something like that. If that is the case, see the link I gave you in my previous answer. for-loops are covered there. OR it may be that you misread the question and did not need a for-loop, in which case also, the link in my previous answer covers how to print numbers to the screen. If what you've written in the question title is the correct, then please ask your computer teacher.
30th Jan 2021, 6:03 AM
XXX
XXX - avatar
+ 1
Ok
30th Jan 2021, 5:38 AM
Shankar Verma
Shankar Verma - avatar
+ 1
Nahi aa Raha hai
30th Jan 2021, 5:41 AM
Shankar Verma
Shankar Verma - avatar
- 1
Shankar Verma normally I would request to see your attempt. However, in consideration that SoloLearn has no BASIC course or examples I will make an exception. 10 dim n as integer 20 dim i as integer 30 print "Enter loop limit: "; 40 input n 50 for i = 1 to n 60 print i 70 next i 80 end Feel free to make adjustments. For instance, line numbers are not needed in QBASIC. They may be removed. Another option is to combine the print and input statement into only an input statement with a string prompt. The index variable i is optional on the "next i" statement, so it may be simplified to just "next". The "end" statement is optional and may be removed. I hope you find it useful!
30th Jan 2021, 9:29 AM
Brian
Brian - avatar