Functions abs is available if you include <stdlib.h>. (abs(x) is the absolute value of x.)

int max(int x, int y)
{
  if(x > y) return x;
  else return y;
}

int heightBalanced(const Node* t)
{
  if(t == NULL) return 0;
  else {
    int x = heightBalanced(t->left);
    int y = heightBalanced(t->right);
    if(x >= 0 && abs(x - y) <= 1) return max(x,y) + 1;
    else return -1;
  }
}