| | |
how to set the range using switch statement??
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 44
Reputation:
Solved Threads: 1
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.....
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.....
0
#2 25 Days Ago
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.
Use if...else if... construct to separate your data points into the appropriate range groups.
"We Americans got so tired of being thought of as dumb by the rest of the world that we went to the polls last November and removed all doubt."
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
![]() |
Similar Threads
- switch statement on String in Java (Java)
- Read string and use in switch statement (C++)
- switch statement (C)
- Switch Statement, Fall-Through. (C)
- Problems with switch statement (C++)
- Problems with switch statement (C++)
Other Threads in the C++ Forum
- Previous Thread: Delete Linked List
- Next Thread: I need some help.
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






