**The result of my program differs from the result of the implementation in the paper, where is the error?**

**I want to calculate this: -1+2-3+4-5+...+ or - N, in PASCAL language, so i write this program but the result is false, Although the method of implementation in the paper**** is correct.**

**So, for example, if I enter the number 4, the result is supposed to be 2, but it prints 10 for me, so where is the error? :**

program x12;

var J,I,N,Y,S:integer;

begin

readln(n);

Y:=0;

S:= N mod 2;

while i<= N do begin

if S=1 then begin Y:=Y-I;

I:=I+1

end

else begin Y:=Y+I;

I:=I+1

end

end;

write(Y)

end.

program x12;

var j,i,n,y,s:integer;

begin

readln(n);

y:=0;

s:= n mod 2;

while i<= n do begin

if s=1 then begin y:=y-i;

i:=i+1;

s:= i mod 2;

end

else begin y:=y+i;

i:=i+1;

s:= i mod 2;

end

end;

write(y)

end.