Answers for "c++ switch multiple cases"

C++
5

c++ switch multiple cases

#include <iostream> 
using namespace std; 
  
int main() { 
    // variable declaration 
	int input;
	switch(input){
	case 1: case 2: case 3: case 4:
		//executes if input is 1, 2, 3, or 4
		break;
	case 5: case 6: case 7:
		//executes if input is 5, 6, or 7
        break;
	default:
		//executes if input isn't any of the cases
    }
    return 0; 
}
Posted by: Guest on September-22-2020

Browse Popular Code Answers by Language