分段函数:如果x为0,则y的值为1000,如果x不为0,y的值为x分之1

求解,有两段代码,第一段不对,第二段为什么对,
第一段
#include
int main(void)
{
int x=0;
float y=0;

scanf("%d",&x);

if (x=0)
{
     printf("y=1000\n");
}
else
{
   printf("y=%f\n",(float)1/x);
}

return 0;

}
第二段
#include
int main(void)
{
int x=0;
float y=0;

scanf("%d",&x);

if (x!=0)
{
  printf("y=%f\n",(float)1/x);
}
else
{

  printf("y=1000\n");
}

return 0;

}

第一段
if(0 == x)

知道为什么写x=0不行吗

知道为什么写x=0不行吗

第一段
if(x == 0)

语法,c系列的 和 vb系列不太一样

if(x==0)
x=0;为赋值语句