program second; uses crt; var x,y,d:real; begin write('Введите значение x '); read(x); y:=-5*x+13; if y>0 then begin write('Введите значение шага преращения '); read(d); end; while y>0 do begin x:=x+d; y:=-5*x+13; end; write(y) end. 

I can not understand what my mistake. Data to check -2 and 0.1.

Closed due to the fact that off-topic participants VenZell , fori1ton , AntonioK , null , Pavel Mayorov May 7, '15 at 7:15 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "Questions asking for help with debugging (" why does this code not work? ") Should include the desired behavior , a specific problem or error, and the minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, complete, repeatable example . " - fori1ton, AntonioK, null, Pavel Mayorov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What did you want and what did you get? - Nicolas Chabanovsky
  • kogda vivodish text pomoemu nujno napisat writeln ('Text'); poprobuy tak esli ne polucitsa napishi - user6131
  • Like you need to find the value of y of the form y = -5 * (x + d) +13, where d is the step of the transformation, to a negative value. The trouble is that I only remember the assignment approximately - Rezox
  • Thank you, but as far as I know, there are no significant differences between write and writeln. - Rezox
  • voobsheto write () dla peremennoy, a writeln () dla texta - user6131

1 answer 1

Well looping as I understand it happens. Do not be lazy and take your own data and run with them and next to write down on paper the result will see the reason. the first substitution -2 gives a loop in the case of while

 begin write('Введите значение x '); read(x); // -2 y:=-5*x+13; 23 if y>0 then // ок прошли дальше begin write('Введите значение шага преращения '); read(d); end; while y>0 do // до сих пор значение 23 пошли по циклу и зациклились begin x:=x+d; y:=-5*x+13; end; write(y) end. 

Is the issue resolved? if not then change the cycle, you don’t need it if the condition

Honestly, the logic of writing your code is completely incomprehensible.

Well, here is the first if you checked, the condition passed, and if not, then what should happen? just go on through the code, this is wrong. well, etc.

What should this small and incomprehensible program do?

  • What about x: = x + d? - Rezox
  • did not see. removed. updated answer. - Artem
  • Look, I calculated for the first time, if a negative value came out right away, you can skip everything and display y. If not, then you need to add 0.1 (or another conversion step) to add to x until y becomes less than zero - Rezox
  • then change the condition. you have if then add more and else and type in this else while - Artem
  • This is not the case, in elsewhere you can only add write (y) - Rezox