0

How to iterate a string over switch case?

In switch case, how to check for strings... Is there any specific way or format to check the iteration of strings over switch case,.. Is the same or is there any other way t carry on the same process with if..else.. as well. Explanation with examples are most welcome!!!! First of all thanks for getting into this question.

6th Apr 2021, 4:44 PM
Vishnuvasan Srinivasan
Vishnuvasan Srinivasan - avatar
4 Answers
+ 2
I'm not understanding your question. If you have a code bit related to this doubt, then share its link so it can be checked. Just follow below guide to share your code bit link. https://www.sololearn.com/post/75089/?ref=app
6th Apr 2021, 5:11 PM
Ipang
+ 1
Case statements only evaluate results. You can put various possible strings in an array, locate the input, then switch on that.
6th Apr 2021, 4:55 PM
Jerry Hobby
Jerry Hobby - avatar
0
Jerry Hobby Sir can be explain it a bit more clearly.... If possible do explain it with a suitable example sir!!!
7th Apr 2021, 2:49 AM
Vishnuvasan Srinivasan
Vishnuvasan Srinivasan - avatar
0
@Vishnuvasan Srinivasan It was fun writing some demo code for you. There are better ways to do this, but SoloLearn doesn't support "vectors". So this is a basic way to do what you asked. Please check this code: https://code.sololearn.com/c0a22A25A49A You can enter multiple commands in input for demonstration. Such as this: up down left badcommand right quit
7th Apr 2021, 6:31 AM
Jerry Hobby
Jerry Hobby - avatar