Language: C

int height(int);

int n;

int main(){
  int i,id,r,l;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].parent=-1;
    u[i].right=-1;
    u[i].left=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    u[id].left=l;
    u[u[id].left].right=r;
    if(u[id].left!=-1) u[u[id].left].parent=id;
    if(u[u[id].left].right!=-1) u[u[u[id].left].right].parent=id;
  }

  for(i=0;i<n;i++){
    if(u[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,degree(i),height(i));

    else if(u[i].left==-1)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));

    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));
  }

  return 0;
}

int sibling(int x){
  if(u[x].right!=-1) return u[x].right;
  else if(u[u[x].parent].left!=x) return u[u[x].parent].left;
  else return -1;
}

int degree(int x){
  if(u[x].left==-1) return 0;
  else if(u[u[x].left].right==-1) return 1;
  else return 2;
}

int depth(int x){
  int d=0,p;
  p=u[x].parent;

  while(p!=-1){
    p=u[p].parent;
    d++;
  }

  return d;
}

int height(int i) {
  int j, x, y;
 
  x = 0;
 
  for(j = 0; j < n; j++) {
    if(u[j].parent == i) {
      y = height(j) + 1;
      if(y > x) x = y;
    }
  }
 
  return x;
}

Compiler output:
main.c: In function 'main':
main.c:8:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    8 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int height(int);
main.c:8:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    8 |   scanf("%d",&n);
      |   ^~~~~
main.c:8:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:11:5: error: 'u' undeclared (first use in this function)
   11 |     u[i].parent=-1;
      |     ^
main.c:11:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:26:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   26 |       printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,degree(i),height(i));
      |       ^~~~~~
main.c:26:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:26:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:26:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:26:98: error: implicit declaration of function 'degree' [-Wimplicit-function-declaration]
   26 |       printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,degree(i),height(i));
      |                                                                                                  ^~~~~~
main.c:29:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   29 |       printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));
      |       ^~~~~~
main.c:29:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:29:111: error: implicit declaration of function 'sibling' [-Wimplicit-function-declaration]
   29 |       printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));
      |                                                                                                               ^~~~~~~
main.c:29:132: error: implicit declaration of function 'depth' [-Wimplicit-function-declaration]
   29 |       printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));
      |                                                                                                                                    ^~~~~
main.c:31:10: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   31 |     else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,sibling(i),degree(i),depth(i),height(i));
      |          ^~~~~~
main.c:31:10: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'sibling':
main.c:38:6: error: 'u' undeclared (first use in this function)
   38 |   if(u[x].right!=-1) return u[x].right;
      |      ^
main.c: In function 'degree':
main.c:44:6: error: 'u' undeclared (first use in this function)
   44 |   if(u[x].left==-1) return 0;
      |      ^
main.c: In function 'depth':
main.c:51:5: error: 'u' undeclared (first use in this function)
   51 |   p=u[x].parent;
      |     ^
main.c: In function 'height':
main.c:67:8: error: 'u' undeclared (first use in this function)
   67 |     if(u[j].parent == i) {
      |        ^