I presume you actually mean:
Code:
if (x == 5)
{
y = x + 3;
printf("y = %f\n", y);
}
In a switch, this might be:
Code:
switch (x)
{
case 5:
y = x + 3;
printf("y = %f\n", y);
break;
}
Or, if you are declaring a variable within a case:
Code:
switch (x)
{
case 5:
{
double y = x + 3;
printf("y = %f\n", y);
}
break;
}
I note that in C++, we usually use output streams like std::cout instead of C-style output functions like printf().
I tried the the fall through one (I did it without break; ), but it didn't add the numbers together. All it did was list them together.
Add what numbers together?