Problem: here's the code.

program fun;
Uses wincrt;

var

y:integer;
ans:integer;
function User(input:integer):integer;
var
   x:integer;
   ans:integer;
Begin
     readln(input);
     ans:=1;
     if (input>0) and (input<100) Then
        begin
        ans:=ans+input
        end
     else
         begin
         x:=User(input);
         halt;
         end;
     User:=ans;
End;

Begin
     ans:=User(y);
     writeln(ans);
end.

when run all work perfectly. when i entered 99 i got the answer 100. This is good.

When i entered a wrong number like 101 then the function is recall to repeat this until the input a right number.
when a right number is entered then the program stop i dont got the answer.

hope u understand wat i mean

any help would be apreciated. thanks

when i remove the line 22 then i get the answer 1 when input 90
help plz.

when i remove the line 22 then i get the answer 1 when input 90
help plz.

the program just writeln the ans and no entered the program for calculation

> hen i remove the line 22 then i get the answer 1 when input 90

That's because on line 21 you assign the answer to x instead of ans. I'd get rid of x too...

This question has already been answered. Start a new discussion instead.