Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Case statements

8 views
Skip to first unread message

Mark

unread,
Jan 22, 2004, 8:59:32 AM1/22/04
to
I am having my first experiences with case statements at the moment.
I am trying to read in a number, the case staement will place the
number in a range and force an output. This works fine with the
following:

1..5:writeln('Blah');
6..10:writeln('blah2');

I was wondering if it is possible to then manipulate the number
specific to that range.
i.e.

1..5:writeln('Blah');
something:=number*10;
6..10:writeln('blah2');
something:=number*11;

Is this possible? Thank you for any help
Mark

Jose Perez

unread,
Jan 22, 2004, 1:17:49 PM1/22/04
to
"Mark" <maa...@hotmail.com> wrote in message
news:76ee55f.04012...@posting.google.com...

Assuming that number is the variable being used in the case statement, yes,
this is a valid way to go. But why ask here? It's easy enough to try.

bluewolf

unread,
Jan 25, 2004, 7:15:29 AM1/25/04
to
maa...@hotmail.com (Mark) wrote in
news:76ee55f.04012...@posting.google.com:

program testcase;
uses crt;
var
tst : byte;
begin
write('Enter a number 1-20');readln(tst);
case tst of
1..5 : begin
writeln; writeln('You choose a number between 1 and 5..');
writeln('I will be adding 4 to that number.');
inc(tst,4);
end;
6..10 : begin
writeln('You number is: ',tst);
writeln('I'll add 3 to that number?!');
inc(tst,3);
end;
end;
writeln('After all that you ended up with the number',tst);
readln;
end.

--
-Onic B.B.S. List - http://plain.solidbox.com/bbslist/ *under
construction*
-Simple B.B.S. - telnet://plain.solidbox.com

0 new messages