switch vs if-else
uhm... which one would be better to use for a menu hack?
BTW these are random examples I made up...
switch -
if-else -
YES I KNOW THEY ARE EQUIVALENT, BUT WHICH IS MORE EFFICIENT?
BTW these are random examples I made up...
switch -
Code:
switch (x) {
case 1:
cout << "x is x";
break;
case 2:
cout << "x is xx";
break;
default:
cout << "value of x unknown";
}
Code:
if (x == 1) {
cout << "x is 1";
}
else if (x == 2) {
cout << "x is 2";
}
else {
cout << "value of x unknown";
}

. But yeah wrong section
