Consider the following code:
#include using namespace std; int main() { int x, y, i; cin >> x >> y >> i; swit
You should put the contents of the case in brackets to give it scope, that way you can declare local variables inside it:
case
switch(i) { case 1: { // int r = x + y; -- OK int r = 1; // Failed to Compile cout << r; } break; case 2: ... break; };