home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!rz.uni-karlsruhe.de!not-for-mail
- From: "hans friedrich steffani" <GM08@DKAUNI2.BITNET>
- Newsgroups: comp.lang.c
- Subject: a question about if and case
- Date: 14 Dec 1992 15:47:20 +0100
- Organization: University of Karlsruhe, Germany
- Lines: 41
- Sender: usenet@nz12.rz.uni-karlsruhe.de
- Distribution: world
- Message-ID: <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de>
-
-
- i have something like
-
- int i;
-
- if( i == 1 || i == 25 || i == 125 )
- {
- /* do something sophisticated */
- }
- if( i == 2 || i == 30 || i == 244 )
- {
- /* do something different */
- }
-
- or should i use
-
- switch( i )
- {
- case 1:
- case 25:
- case 125:
- /* do something sophisticated */
- break;
-
- case 2:
- case 30
- case 244:
- /* do something different */
- break;
-
- default:
- break
- }
-
- or is there a third way??
- i need contructions like this very often so i need a GOOD
- solution.
-
- hans friedrich steffani@imbaibrs1.bau-verm.uni-karlsruhe
- steffani gm08@rz.uni-karlsruhe.de
- gm08@dkauni2.bitnet
-