[Solved] which code execute faster?


Given what you have posted,

Example 1

int d;
d=0;
d=a+b;
/* print d+c+e;*/
printf("%i\n", d+c+e);

Example 2

/* print a+b+c+e; */
printf("%i\n", a+b+c+e);

Which is faster is tricky, if your compiler optimizes d away in Example 1 they are equivalent. On the other hand, if your compiler can’t determine that d=0 is discarded (and it may not) then it can’t decide that d is really const int d = a+b; and the examples will not be equivalent with Example 2 being (slightly) faster.

solved which code execute faster?