Beginner, Please Help

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
guest1

Beginner, Please Help

Post by guest1 »

I need to write a program that accepts a number and finds an integer whose square is less than the number entered using only do loop and no other functions. I can use only one input and one output variable.
This is what I have and it's wrong:
cls
max=max-1
input "please enter a number"; max
do until max2<max
max2=(max*max)
loop
print max2

Can you help?
abionnnn
Newbie
Posts: 6
Joined: Mon Oct 04, 2004 2:54 pm
Location: Coming soon to a store near you
Contact:

Post by abionnnn »

>I need to write a program that accepts a number and finds an integer whose square is less than the number entered using only do loop and no other functions.

The way you worded it, given the number is positive then 0 is a correct answer for any number. That's not too bad =) Your code wont work. I think you need to write what you want to do on paper and then do it in chronological order. This would do just fine:

Code: Select all

INPUT n&
i& = 0
DO UNTIL i&*i& >= n&
 i& = i& + 1
LOOP
PRINT i& - 1
Note the >=.

-abionnnn
Post Reply