Ok, i just started using pascal, since I went to a college open evening, and they told me in the first year of the course I wish to study, i would be learning pascal. This is not a homework assignment of any kind, this is just me messing around with pascal, trying to gain some knowledge.
In writing, my problem is this. I need to take the smallest of two variables that have previously been inputted from the biggest of the two, however, either of the variables could be the biggest, or the smallest.
I've been told to use something called min/max function, which I understand I need to use begin and end again, something i've not done yet. So far, I think i've got it, but I get exitcode 201 when i run and it gets to that point.
I have done this, yet it doesn't work.
The variables are gain,gain2,max,min and resul. All are correctly declared as the correct data types.
if gain < gain2 then
begin
Min:=gain;
Max:=gain2;
end;
else
if gain2 < gain then
begin
Min:=gain2;
Max:=gain;
end;
resul:= Max - Min;
writeln('Your answer is ')
write( resul )
Now, i'm sure this is the correct idea, correct me if i'm wrong. If this is right, do I have something in the wrong place? If its wrong, i'd be greatful for some help, but not an outright answer, i won't learn anything from copying what someone else writes.
Thanks in advance, I hope someone can help me.