else if(0) always evaluates to false. Did you mean else if (x == 0)?
else if(x=-2) assigns the value -2 to x. Probably you want to check equality like else if (x == -2).
The x == -2 check must come before the x < -1.5 as -2 is less than -1.5, so the first condition will always be true and y will be set to 1.
Something like this would work:
#include <stdio.h>
int main()
{
float y;
float x;
printf("Number x: ");
scanf("%f", &x);
if (x == -2.0f)
{
y = 0;
}
else if (x < -1.5f)
{
y = 1;
}
else if (x == 0.0f)
{
y = 0;
}
else if (x >= 1.0f)
{
y = 1;
}
else
{
y = -2;
}
printf("y = %f\n", y);
return 0;
}