Suppose I have a variable that depends on a condition. From the efficiency perspective, should I use
int s;
if (d > 2)
{
s = -1;
}
else
{
s = 1;
}
or just
int s = 1;
if (d > 2)
{
s = -1;
}
Can someone explain the difference? Is there any difference between a compiled language (e.g. C) vs an interpreted one (e.g. Python)?
Notice that this question is related with a previous question of mine, and the reason I'm asking is the same: it is very frequent in any programming language, and I always end up asking myself what should I use.