home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!hobbes.physics.uiowa.edu!news.iastate.edu!niko
- From: niko@iastate.edu (Nikolaus E Schuessler)
- Subject: Re: C if else statements HELP
- Message-ID: <C0JqG6.Ers@news.iastate.edu>
- Sender: news@news.iastate.edu (USENET News System)
- Organization: Iowa State University, Ames, IA
- References: <1993Jan8.160740.22055@magnus.acs.ohio-state.edu>
- Date: Fri, 8 Jan 1993 17:40:46 GMT
- Lines: 50
-
- In article <1993Jan8.160740.22055@magnus.acs.ohio-state.edu> ctoth@magnus.acs.ohio-state.edu (Christopher M Toth) writes:
- > Hi! I just started learning C and have run into problems with
- >'if' and'else' statements. I have a program that I am *trying* to write. The
- >basic format is:
- >
- > printf ("which do you choose?");
- > scanf("%d", &n);
- > choice#1
- > choice#2
- > choice#3
- > choice#4
- >
- > if choice #1
- > printf.....
- > if choice #2
- > printf.....
- > if choice #3
- > printf.....
- > if choice #4
- > printf.....
- >
-
- how about:
-
- switch (n) {
-
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
-
- default:
- break;
- }
-
- This will only work on certain types though (ints, chars ...)
-
- If you don't already have it, you should get the Kernigan and Richie
- C book.
-
-
- --
- Niko Schuessler
- Project Vincent Systems Manager email: niko@iastate.edu
- Iowa State University Computation Center voice: (515) 294-1672
- Ames IA 50011 snail: 272 Durham
-