OK so I am trying to get Pascal to read a set of integers from a input file then take the even numbers and add them together with in the range of 1-50. Not working for me. Here is what I have: List of input file numbers 1 2 3 4 5 6 7 8 9 11 12 64 13 14 15 16 71 33 34 35 36 41 44 46 82 512 49 50 And my pascal program:
program even(input,output,indata);
uses crt;
Var
indata:text;
num, even:integer;
begin
clrscr;
assign(indata, 'j:\num.txt');
reset(indata)0;
read(indata, num);
while num>50 do
begin
read(indata, num);
if num mod 2=0 then
even:=even+num;
end;
writeln('Even sum is', even);
readln( );
end.
Any help would be great! When I run it I get text as "Even sum is 0".