944,117 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1257
  • C++ RSS
Nov 2nd, 2009
0

how to set the range using switch statement??

Expand Post »
Hi..
Is that possible to us to set the range using the switch statement?
For example i want to do this :
if ph==7 is neutral
if ph<7 is acidic
if ph>7 is alkali

could i just write like "case ph<7 :"
i know i could do the case one by one by writing case 1 :,case 2 and so on..
but if i got a big range...how could i do that??
Thank You.....
Similar Threads
Reputation Points: 6
Solved Threads: 1
Posting Whiz in Training
samsons17 is offline Offline
225 posts
since Oct 2009
Nov 2nd, 2009
0
Re: how to set the range using switch statement??
switch blocks are not good for doing range based decision making. You have to be able to do exact matches to integral types, which is often, as you surmise, way too much work.

Use if...else if... construct to separate your data points into the appropriate range groups.
Reputation Points: 1268
Solved Threads: 228
Posting Virtuoso
vmanes is offline Offline
1,895 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Delete Linked List
Next Thread in C++ Forum Timeline: I need some help.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC