How to write a program using to switch print a from 0 to 49 and to print b from 50 to 64 and print c from 65 to 74 and .... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a program using to switch print a from 0 to 49 and to print b from 50 to 64 and print c from 65 to 74 and ....

to print d from 75 to 84 and to print e from 85 to 100

20th Feb 2017, 6:23 PM
Ali Zeawo
Ali Zeawo - avatar
2 Answers
+ 5
You can, but you have to check every single value in the cases for equality then. Use ranges in if/else statements. Switch ranges are the cplusplussy-way ^^
20th Feb 2017, 8:48 PM
Tashi N
Tashi N - avatar
+ 1
You cant as here you're not making comparison against a constant for equality. You need to go for if-else.
20th Feb 2017, 8:01 PM
Daniel
Daniel - avatar