There are a lot of ways in C++ to achieve selection structure.
- if else (basically every programming language have it)
if (a)
{
//do something
}
else
{
//do something else
}
- switch control
switch (input)
{
case a:
// do something
break;
case b:
// do something else
break;
default:
// default when the user input is not expected a or b
}
- labels and goto keyword
int main(void)
{
//something....
if (a) goto label_a;
else if (b) goto label_b;
label_a:
//something...
goto end;
label_b:
//something else
goto end;
end:
return 0;
}
- Function calls
void first() { /*something*/ }
void second() { /*something else*/ }
int main(void)
{
//your previous codes
if (a)
{
first();
}
else
{
if (b)
{
second();
}
}
return 0;
}
More things to read: CPlusPlus Statements and Controls
Or you can invest some money to buy a good C++ Reference books like C++ Primer