Language: C

int degree(int);
int depth(int);
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[u[id].left].right].parent=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:10:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   10 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int degree(int);
main.c:10:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   10 |   scanf("%d",&n);
      |   ^~~~~
main.c:10:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:13:5: error: 'u' undeclared (first use in this function)
   13 |     u[i].parent=-1;
      |     ^
main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   28 |       printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,degree(i),height(i));
      |       ^~~~~~
main.c:28:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:28:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:31:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   31 |       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:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:31:111: error: implicit declaration of function 'sibling' [-Wimplicit-function-declaration]
   31 |       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:33:10: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   33 |     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:33:10: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'sibling':
main.c:40:6: error: 'u' undeclared (first use in this function)
   40 |   if(u[x].right!=-1) return u[x].right;
      |      ^
main.c: In function 'degree':
main.c:46:6: error: 'u' undeclared (first use in this function)
   46 |   if(u[x].left==-1) return 0;
      |      ^
main.c: In function 'depth':
main.c:53:5: error: 'u' undeclared (first use in this function)
   53 |   p=u[x].parent;
      |     ^
main.c: In function 'height':
main.c:69:8: error: 'u' undeclared (first use in this function)
   69 |     if(u[j].parent == i) {
      |        ^