I ran the following codes using ideone.com:
#include <stdio.h>
int main(void)
{
    int i,j=0;
    if(j)
    {
        j=0; //To suppress the warning that j is not used
        i=1;
    }
    printf("%d\n",i);
}
Output: Garbage value:
 #include <stdio.h>
 int main(void)
 {
      int i;
      if(0)
      {         
        i=1;
      }
      printf("%d\n",i);
 }
Output:
Error: unitialized local variable i used.
Is it because the compiler removes the if(0) block completely while optimizing? And such an optimization cannot be done in case of if(j) since it is a variable? Won't value of j be present at compile-time and the same optimization must be done? Or is it that memory is allocated at run-time only?
 
     
     
    