Language: C

int height(int);
data A[25];
int B[25];
int depthmax=0;
int main(){
  int N,i,id,l,r,root;

  scanf("%d",&N);

  for(i=0;i<N;i++) {
    A[i].parent=NIL;
    A[i].sibling=NIL;
  }
    for(i=0;i<N;i++){
    scanf("%d%d%d",&id,&l,&r);
    if(id==0)root=i;
    A[i].left=l;
    A[i].right=r;
    if(l!=NIL) A[l].parent=id;
    if(r!=NIL) A[r].parent=id;
    }
   
  
  preparse(root);
  sibling(root,A[root].right,A[root].left);
  degree(root);
  height(root);
  
  for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);  
    if(A[i].parent==NIL) printf("root\n");
    else if(A[i].right==NIL&&A[i].left==NIL) printf("leaf\n");
    else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
  
  }
  return 0;
}

void preparse(int u){
  static int count;
 
  if(u==NIL) return;

  A[u].depth=count;
  if(A[u].depth>depthmax) depthmax=A[u].depth;
  count++;
  preparse(A[u].left);
  preparse(A[u].right);
  count--;
}

void sibling(int u,int r,int l){
  int i;

  if(u==NIL) return;
  if(A[u].left!=NIL && A[u].right!=NIL) {
    A[l].sibling=A[u].right;   
    A[r].sibling=A[u].left;
  }

  sibling(A[u].left,A[l].right,A[l].left);
  sibling(A[u].right,A[r].right,A[r].left);
  
}
  
void degree(int u){
  if(u==NIL) return;
  if(A[u].left!=NIL && A[u].right!=NIL) A[u].degree=2;
  else if((A[u].left==NIL && A[u].right!=NIL) || (A[u].left!=NIL && A[u].right==NIL)) A[u].degree=1;
  else A[u].degree=0;

  degree(A[u].left);
  degree(A[u].right);
}

int height(int u){
  int h1=0,h2=0;
  if(A[u].left!=NIL) h1=height(A[u].left)+1;
  if(A[u].right!=NIL) h2=height(A[u].right)+1;

if(h1>h2) B[u]=h1;
      else B[u]=h2;
 A[u].height=B[u];
 
 return B[u]; 
}

Compiler output:
main.c:2:1: error: unknown type name 'data'
    2 | data A[25];
      | ^~~~
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:9: error: request for member 'parent' in something not a structure or union
   11 |     A[i].parent=NIL;
      |         ^
main.c:11:17: error: 'NIL' undeclared (first use in this function)
   11 |     A[i].parent=NIL;
      |                 ^~~
main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:12:9: error: request for member 'sibling' in something not a structure or union
   12 |     A[i].sibling=NIL;
      |         ^
main.c:17:9: error: request for member 'left' in something not a structure or union
   17 |     A[i].left=l;
      |         ^
main.c:18:9: error: request for member 'right' in something not a structure or union
   18 |     A[i].right=r;
      |         ^
main.c:19:20: error: request for member 'parent' in something not a structure or union
   19 |     if(l!=NIL) A[l].parent=id;
      |                    ^
main.c:20:20: error: request for member 'parent' in something not a structure or union
   20 |     if(r!=NIL) A[r].parent=id;
      |                    ^
main.c:24:3: error: implicit declaration of function 'preparse' [-Wimplicit-function-declaration]
   24 |   preparse(root);
      |   ^~~~~~~~
main.c:25:3: error: implicit declaration of function 'sibling' [-Wimplicit-function-declaration]
   25 |   sibling(root,A[root].right,A[root].left);
      |   ^~~~~~~
main.c:25:23: error: request for member 'right' in something not a structure or union
   25 |   sibling(root,A[root].right,A[root].left);
      |                       ^
main.c:25:37: error: request for member 'left' in something not a structure or union
   25 |   sibling(root,A[root].right,A[root].left);
      |                                     ^
main.c:26:3: error: implicit declaration of function 'degree' [-Wimplicit-function-declaration]
   26 |   degree(root);
      |   ^~~~~~
main.c:29:21: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                     ^~~~~~
main.c:29:21: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:29:21: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:29:21: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:29:111: error: request for member 'parent' in something not a structure or union
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                                                                                                               ^
main.c:29:123: error: request for member 'sibling' in something not a structure or union
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                                                                                                                           ^
main.c:29:136: error: request for member 'degree' in something not a structure or union
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                                                                                                                                        ^
main.c:29:148: error: request for member 'depth' in something not a structure or union
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                                                                                                                                                    ^
main.c:29:159: error: request for member 'height' in something not a structure or union
   29 |   for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);
      |                                                                                                                                                               ^
main.c:30:12: error: request for member 'parent' in something not a structure or union
   30 |     if(A[i].parent==NIL) printf("root\n");
      |            ^
main.c:31:17: error: request for member 'right' in something not a structure or union
   31 |     else if(A[i].right==NIL&&A[i].left==NIL) printf("leaf\n");
      |                 ^
main.c:31:34: error: request for member 'left' in something not a structure or union
   31 |     else if(A[i].right==NIL&&A[i].left==NIL) printf("leaf\n");
      |                                  ^
main.c:32:18: error: request for member 'right' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                  ^
main.c:32:35: error: request for member 'left' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                                   ^
main.c:32:53: error: request for member 'right' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                                                     ^
main.c:32:70: error: request for member 'left' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                                                                      ^
main.c:32:88: error: request for member 'right' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                                                                                        ^
main.c:32:105: error: request for member 'left' in something not a structure or union
   32 |     else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
      |                                                                                                         ^
main.c: At top level:
main.c:38:6: warning: conflicting types for 'preparse'; have 'void(int)'
   38 | void preparse(int u){
      |      ^~~~~~~~
main.c:24:3: note: previous implicit declaration of 'preparse' with type 'void(int)'
   24 |   preparse(root);
      |   ^~~~~~~~
main.c: In function 'preparse':
main.c:41:9: error: 'NIL' undeclared (first use in this function)
   41 |   if(u==NIL) return;
      |         ^~~
main.c:43:7: error: request for member 'depth' in something not a structure or union
   43 |   A[u].depth=count;
      |       ^
main.c:44:10: error: request for member 'depth' in something not a structure or union
   44 |   if(A[u].depth>depthmax) depthmax=A[u].depth;
      |          ^
main.c:44:40: error: request for member 'depth' in something not a structure or union
   44 |   if(A[u].depth>depthmax) depthmax=A[u].depth;
      |                                        ^
main.c:46:16: error: request for member 'left' in something not a structure or union
   46 |   preparse(A[u].left);
      |                ^
main.c:47:16: error: request for member 'right' in something not a structure or union
   47 |   preparse(A[u].right);
      |                ^
main.c: At top level:
main.c:51:6: warning: conflicting types for 'sibling'; have 'void(int,  int,  int)'
   51 | void sibling(int u,int r,int l){
      |      ^~~~~~~
main.c:25:3: note: previous implicit declaration of 'sibling' with type 'void(int,  int,  int)'
   25 |   sibling(root,A[root].right,A[root].left);
      |   ^~~~~~~
main.c: In function 'sibling':
main.c:54:9: error: 'NIL' undeclared (first use in this function)
   54 |   if(u==NIL) return;
      |         ^~~
main.c:55:10: error: request for member 'left' in something not a structure or union
   55 |   if(A[u].left!=NIL && A[u].right!=NIL) {
      |          ^
main.c:55:28: error: request for member 'right' in something not a structure or union
   55 |   if(A[u].left!=NIL && A[u].right!=NIL) {
      |                            ^
main.c:56:9: error: request for member 'sibling' in something not a structure or union
   56 |     A[l].sibling=A[u].right;
      |         ^
main.c:56:22: error: request for member 'right' in something not a structure or union
   56 |     A[l].sibling=A[u].right;
      |                      ^
main.c:57:9: error: request for member 'sibling' in something not a structure or union
   57 |     A[r].sibling=A[u].left;
      |         ^
main.c:57:22: error: request for member 'left' in something not a structure or union
   57 |     A[r].sibling=A[u].left;
      |                      ^
main.c:60:15: error: request for member 'left' in something not a structure or union
   60 |   sibling(A[u].left,A[l].right,A[l].left);
      |               ^
main.c:60:25: error: request fo