473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
5 1124
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
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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Markku Uttula | last post by:
I think I'm doing something wrong. I'm able to connect to Oracle just fine, execute queries and all, but I'm having serious problems with the speed :( For example, the following PHP-script on my...
11
by: Sean Cody | last post by:
I'm trying to take a webpage that has a nxn table of entries (bus times) and convert it to a 2D array (list of lists). Initially this was simple but I need to be able to access whole 'columns' of...
3
by: Carlos Ribeiro | last post by:
As a side track of my latest investigations, I began to rely heavily on generators for some stuff where I would previsouly use a more conventional approach. Whenever I need to process a list, I'm...
8
by: CAFxX | last post by:
i'm writing a program that executes some calculations on a bitmap loaded in memory. these calculation ends up with pixel wth values far over 255, but i need them to be between 0 and 255 since i...
1
by: cwdjrxyz | last post by:
I am now writing many new pages in xhtml 1.1. They are served as true xhtml by setting the mime type of the server to application/xhtml+xml for the .xhtml extension. Since IE6 and some earlier...
0
by: psql-mail | last post by:
I am trying to use the fti module to search my text. Searching through the raw text using ILIKE takes 3 seconds, searching using fti takes 212 seconds. Then i tried to turn off seq_scan to see...
2
by: shblack | last post by:
I need help with a program I am writing for school. The program has to do the following: /* 1. Character string must be a minimium of 15 charactors. 2. If not 15 characters long it must give...
4
by: paduffy | last post by:
Folks, I've a Python 2.5 app running on 32 bit Win 2k SP4 (NTFS volume). Reading a file of 13 GBytes, one line at a time. It appears that, once the read line passes the 4 GByte boundary, I am...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.