By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,836 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

I'm new at C, and I'm having problems with descisions and loops

P: n/a
Hi,
I need to create a program that prompts the user to either select
options 1,2,3 or 4, or type end to end the program. The user must be
able to select any option as may times as he or she wants, unitl
he/she types end. I've got a switch going, (as well as using a while
to repeat the switch) and I'm aware it only accepts ints, so i was
thinking of putting an if/else statement around it, something like if
the input is an int, do the switch, else close the program. can anyone
help me?
Thanks,

James
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
James <ji****@hotmail.com> wrote:
can anyone help me?


Most certainly. Why don't you post what you've got.
--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===
Nov 13 '05 #2

P: n/a
On 22 Nov 2003 08:23:51 -0800, ji****@hotmail.com (James) wrote:
Hi,
I need to create a program that prompts the user to either select
options 1,2,3 or 4, or type end to end the program. The user must be
able to select any option as may times as he or she wants, unitl
he/she types end. I've got a switch going, (as well as using a while
to repeat the switch) and I'm aware it only accepts ints, so i was
thinking of putting an if/else statement around it, something like if
the input is an int, do the switch, else close the program. can anyone
help me?
Thanks,

James


When I have written similar programs, I just use "5" as an aption for
"end".
Nov 13 '05 #3

P: n/a

"James" <ji****@hotmail.com> wrote in message
news:14**************************@posting.google.c om...
Hi,
I need to create a program that prompts the user to either select
options 1,2,3 or 4, or type end to end the program. The user must be
able to select any option as may times as he or she wants, unitl
he/she types end. I've got a switch going, (as well as using a while
to repeat the switch) and I'm aware it only accepts ints, so i was
thinking of putting an if/else statement around it, something like if
the input is an int, do the switch, else close the program. can anyone
help me?
Thanks,


I once called my dentist when I had a toothache, but darn him,
he insisted that before he could fix it, he needed to actually
look into my mouth.

-Mike
Nov 13 '05 #4

P: n/a
James wrote:

Hi,
I need to create a program that prompts the user to either select
options 1,2,3 or 4, or type end to end the program. The user must be
able to select any option as may times as he or she wants, unitl
he/she types end. I've got a switch going, (as well as using a while
to repeat the switch) and I'm aware it only accepts ints, so i was
thinking of putting an if/else statement around it, something like if
the input is an int, do the switch, else close the program. can anyone
help me?
Thanks,

James


Write the program as a finite state machine rather than as decisions cum
loops. It will be much cleaner.

--
Julian V. Noble
Professor Emeritus of Physics
jv*@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/

"God is not willing to do everything, and thereby take away that
share of glory that rightfully belongs to ourselves."

-- N. Machiavelli, "The Prince".
Nov 13 '05 #5

P: n/a
dfg
Julian V. Noble wrote:
James wrote:
Hi,
I need to create a program that prompts the user to either select
options 1,2,3 or 4, or type end to end the program. The user must be
able to select any option as may times as he or she wants, unitl
he/she types end. I've got a switch going, (as well as using a while
to repeat the switch) and I'm aware it only accepts ints, so i was
thinking of putting an if/else statement around it, something like if
the input is an int, do the switch, else close the program. can anyone
help me?
Thanks,

James

Write the program as a finite state machine rather than as decisions cum
loops. It will be much cleaner.


He is a beginner though. Is a Finite state machine easy enough to
understand for someone new to programming?

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.