0

Can i write a case as case(m>=80&&m<=100):

23rd Dec 2017, 7:38 PM
Hamna
3 Answers
+ 4
Not likely, but without knowing the programming language it is impossible to say. If you ask another question in the future, try to ask it completely as this posts states. https://www.sololearn.com/Discuss/333866/?ref=app There are languages that I've used that support that, but of the ones available here that I know it isn't supported.
23rd Dec 2017, 9:37 PM
John Wells
John Wells - avatar
+ 3
In C++ ranged value evaluation using switch...case is not possible (cmiiw), however, you can resort to using multiple case statements grouped to check for a range of value. Since you are obliged to use switch...case, here's what I would suggest you to do, this example checks for score between 80-100 to output 'A'. Other cases statements for various results are yours to implement. Hth, cmiiw #include <iostream> using namespace std; int main() { int score {0}; cout << "Enter student score: "; cin >> score; cout << score << endl; switch(score) { case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: cout << "A"; break; default: cout << "Invalid score"; } return 0; }
24th Dec 2017, 5:35 AM
Ipang
+ 1
i am using c ++ and the program is to print A grade if marks are greater than 80 and less than 100 . print B if marks are .. and so on ....i have to do tgi using switch statement.
24th Dec 2017, 5:00 AM
Hamna