Reputation:
I'm coding a little program but it won't print out the right math answer, it just stays at 993. The Code:
program _Gul_;
uses crt;
var a: integer;
var b: integer;
begin
writeln('1000 - 7?');
a := 1000;
b := a - 7;
while a > 0 do
begin
writeln (a - 7, ' - 7?');
delay(120);
a := a - 7;
writeln (b)
if a = 6 then
break;
end;
writeln('я гуль')
end
I don't quite know why it is not working. I defined "b" and made a command that prints it out and the output is just:
Upvotes: 1
Views: 47
Reputation: 36536
You never update the value in b
. In point of fact, b
is not necessary to your program at all. Your printing strategy is also more complicated than it needs to be. Print a
minus 7
, then do the subtraction and print it. This prevents the program telling you the rest of 6 - 7
is 6
.
program _Gul_;
uses
crt;
var
a: integer;
begin
a := 1000;
while a > 0 do
begin
writeln (a, ' - 7?');
delay(120);
a := a - 7;
writeln (a);
if a = 6 then
break;
end;
writeln('я гуль')
end.
Upvotes: 1