tags:

views:

442

answers:

2

Hello there! I'm having trouble making this work. Apparently, i can't use > or < in the case sentence, is there a workaround for this? Thanks!

case num of
    0:
        begin
            cont_0 := cont_0 + 1;
        end;
    > 0:
        begin
            cont_pos := cont_pos + 1;
            sum_pos  := sum_pos + num;
        end;
    < 0:
        begin
            sum_neg := sum_neg + num;
        end;  
    else;
end;
A: 

Don't use case then, why not use if?

if num = 0 then
        cont_0 := cont_0 + 1;
if num > 0 then
BEGIN
        cont_pos := cont_pos + 1;
        sum_pos  := sum_pos + num;
END
if num < 0 then
        sum_neg := sum_neg + num;
voyager
In the flow chart i used CASE, i like it more. Less bulky. Thanks anyway!
Gabriel A. Zorrilla
+4  A: 
case Sign(num) of
    -1: ... 
     0: ...
     1: ...
end;

More readable than if ... else if ... else? You decide.

Kha
Lovely, classy. Thanks!
Gabriel A. Zorrilla