0

how can we use cin>> in switch to enter a value that can match with the case

21st Jul 2016, 10:13 PM
Khan Zeeshan
Khan Zeeshan - avatar
2 odpowiedzi
0
A switch statement can't use strings as input. The best alternative is to use multiple if statements. another option is to link words to numbers and use these numbers as input instead of the word itself.
21st Jul 2016, 10:30 PM
Dennis Reep
Dennis Reep - avatar
0
for ex: void main() { int x; cin>>x; switch(x) { case 1: cout<<"……"; break; … … case n: cout<<"……"; break;}
17th Oct 2016, 6:50 AM
gurinder sandhu
gurinder sandhu - avatar