## intel1111

I am currently learning Pascal at school an I'm thought i was getting pretty efficient until i was set work on the repeat until loop. I was working on a program that squares then cubes a number until a rouge value of -9999.99 but it won't!

``````(* Author: Tony Diec
Date: Tuesday, 23rd September 2008
Description: Squares And Cubes Numbers.
*)

program SquareCube;

var
Num1, Square, Cube : real;

procedure Obtain;
begin
Square := Num1 * Num1;
writeln (Num1,' Squared = ',Square);
Cube := Square * Num1;
writeln (Num1,' Cubed = ',Cube);
writeln ('Input The Number You Would Like To Square And Cube');
writeln ('WARNING! Entering -9999.99 Will End Program');
end;
procedure ObtainNum;
begin
writeln ('Input The Number You Would Like To Square And Cube');
writeln ('WARNING! Entering -9999.99 Will End Program');
repeat
Obtain
until Num1 = -9999.99;
end;

begin

ObtainNum;

end.``````

## Ranfile

you didnt change the numl and expect your code to stop looping when numl reach -9999.99.

maybe you should consider if else statement...not looping:)

or substract the numl...so the numl reach the number...

anyway,its very risky to loop until an amount of number with decimal in it and "=" operation.use > or < instead:)

## MoZo1 -3

First, an if would be nicer, but then he should use break, and that's forbidden in school.
And then he doesn't have to increase Numl, because it's reobtained inside the loop. You're supposed to input that value exactly, so the = is also fine here. You can't see this, because it's a proc oriented code with global variables. This is exactly why OO is cool.
And just for help for those who want to test it on delphi: use .dpr extension, and add the {\$Apptype console} directive.
Oh, and the bug at last: I don't see where are you from in your profile, but I'm from Hungary, and I had to input "-9999,99" instead of "9999.99". Try hitting the decimal on your numpad, it's always the right one. But more importantly it works for me as it is, so try changing that lot of 9s to a 0, that will work the same way everywhere.