Page 1 of 1

Beginner, Please Help

Posted: Thu Oct 07, 2004 11:50 am
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?

Posted: Thu Oct 07, 2004 3:50 pm
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