Language: C

void insert(int);
void delete(NodePointer);
void deleteFirst(void);
void deleteLast(void);
NodePointer findkey(int);
 
NodePointer nil;

int main(){

  int i,in,n;
  char s[20];
  NodePointer x;

  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;

  scanf("%d",&n);

  i=0;
  while(i!=n){

    memset(s,'\0',20);
    scanf("%s",s);
    i++;
      if(strcmp(s,"insert")==0){
	scanf("%d",&in);
	insert(in);
      }
      else if(strcmp(s,"delete")==0){
	scanf("%d",&in);
	x=findkey(in);
	if(x->next==nil) continue;
	else delete(x);
      }
      else if(strcmp(s,"deleteFirst")==0) {
	deleteFirst();
      }
      else if(strcmp(s,"deleteLast")==0){
	  deleteLast();
	}
  }
	
	
  for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
  
 printf("%d\n",x->key);


  return 0;
}

void insert(int x){

  NodePointer new;

  new=malloc(sizeof(struct node));

  new->key=x;
  new->next=nil->next;
  nil->next->prev=new;
  nil->next=new;
  new->prev=nil;

}

void delete(NodePointer delnode){

  delnode->prev->next=delnode->next;
  delnode->next->prev=delnode->prev;
  free(delnode);

}

NodePointer findkey(int x){

  NodePointer tmp;

  tmp=malloc(sizeof(struct node));

  tmp=nil->next;
  while(tmp->next!=nil && tmp->key!=x){
    tmp=tmp->next;
  }

  return tmp;
}

void deleteFirst(void){
  NodePointer delnode;
  delnode=nil->next;

  if(delnode->next==nil){
    nil->next=nil;
    nil->prev=nil;
    free(delnode);
  }
  else{
    nil->next=delnode->next;
    delnode->next->prev=delnode->prev;
    free(delnode);
  }
  

}

void deleteLast(void){

  NodePointer delnode;

  for(delnode=nil->next;delnode->next!=nil;delnode=delnode->next);

  delnode->prev->next=nil;
  nil->prev=delnode->prev;

  free(delnode);
}

Compiler output:
main.c:2:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
    2 | void delete(NodePointer);
      | ^~~~
main.c:5:1: error: unknown type name 'NodePointer'
    5 | NodePointer findkey(int);
      | ^~~~~~~~~~~
main.c:7:1: error: unknown type name 'NodePointer'
    7 | NodePointer nil;
      | ^~~~~~~~~~~
main.c: In function 'main':
main.c:13:3: error: unknown type name 'NodePointer'
   13 |   NodePointer x;
      |   ^~~~~~~~~~~
main.c:15:7: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   15 |   nil=malloc(sizeof(struct node));
      |       ^~~~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
  +++ |+#include <stdlib.h>
    1 | void insert(int);
main.c:15:7: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   15 |   nil=malloc(sizeof(struct node));
      |       ^~~~~~
main.c:15:7: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:15:21: error: invalid application of 'sizeof' to incomplete type 'struct node'
   15 |   nil=malloc(sizeof(struct node));
      |                     ^~~~~~
main.c:16:6: error: invalid type argument of '->' (have 'int')
   16 |   nil->next=nil;
      |      ^~
main.c:17:6: error: invalid type argument of '->' (have 'int')
   17 |   nil->prev=nil;
      |      ^~
main.c:19:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | void insert(int);
main.c:19:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   19 |   scanf("%d",&n);
      |   ^~~~~
main.c:19:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:24:5: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
   24 |     memset(s,'\0',20);
      |     ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset'
  +++ |+#include <string.h>
    1 | void insert(int);
main.c:24:5: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
   24 |     memset(s,'\0',20);
      |     ^~~~~~
main.c:24:5: note: include '<string.h>' or provide a declaration of 'memset'
main.c:27:10: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
   27 |       if(strcmp(s,"insert")==0){
      |          ^~~~~~
main.c:27:10: note: include '<string.h>' or provide a declaration of 'strcmp'
main.c:34:13: error: invalid type argument of '->' (have 'int')
   34 |         if(x->next==nil) continue;
      |             ^~
main.c:46:12: error: invalid type argument of '->' (have 'int')
   46 |   for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
      |            ^~
main.c:46:20: error: invalid type argument of '->' (have 'int')
   46 |   for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
      |                    ^~
main.c:46:35: error: invalid type argument of '->' (have 'int')
   46 |   for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
      |                                   ^~
main.c:46:43: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   46 |   for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
      |                                           ^~~~~~
main.c:46:43: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:46:43: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:46:43: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:46:57: error: invalid type argument of '->' (have 'int')
   46 |   for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
      |                                                         ^~
main.c:48:2: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   48 |  printf("%d\n",x->key);
      |  ^~~~~~
main.c:48:2: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:48:17: error: invalid type argument of '->' (have 'int')
   48 |  printf("%d\n",x->key);
      |                 ^~
main.c: In function 'insert':
main.c:56:3: error: unknown type name 'NodePointer'
   56 |   NodePointer new;
      |   ^~~~~~~~~~~
main.c:58:7: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   58 |   new=malloc(sizeof(struct node));
      |       ^~~~~~
main.c:58:7: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:58:21: error: invalid application of 'sizeof' to incomplete type 'struct node'
   58 |   new=malloc(sizeof(struct node));
      |                     ^~~~~~
main.c:60:6: error: invalid type argument of '->' (have 'int')
   60 |   new->key=x;
      |      ^~
main.c:61:6: error: invalid type argument of '->' (have 'int')
   61 |   new->next=nil->next;
      |      ^~
main.c:61:16: error: invalid type argument of '->' (have 'int')
   61 |   new->next=nil->next;
      |                ^~
main.c:62:6: error: invalid type argument of '->' (have 'int')
   62 |   nil->next->prev=new;
      |      ^~
main.c:63:6: error: invalid type argument of '->' (have 'int')
   63 |   nil->next=new;
      |      ^~
main.c:64:6: error: invalid type argument of '->' (have 'int')
   64 |   new->prev=nil;
      |      ^~
main.c: At top level:
main.c:68:13: error: unknown type name 'NodePointer'
   68 | void delete(NodePointer delnode){
      |             ^~~~~~~~~~~
main.c:76:1: error: unknown type name 'NodePointer'
   76 | NodePointer findkey(int x){
      | ^~~~~~~~~~~
main.c: In function 'findkey':
main.c:78:3: error: unknown type name 'NodePointer'
   78 |   NodePointer tmp;
      |   ^~~~~~~~~~~
main.c:80:7: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   80 |   tmp=malloc(sizeof(struct node));
      |       ^~~~~~
main.c:80:7: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:80:21: error: invalid application of 'sizeof' to incomplete type 'struct node'
   80 |   tmp=malloc(sizeof(struct node));
      |                     ^~~~~~
main.c:82:10: error: invalid type argument of '->' (have 'int')
   82 |   tmp=nil->next;
      |          ^~
main.c:83:12: error: invalid type argument of '->' (have 'int')
   83 |   while(tmp->next!=nil && tmp->key!=x){
      |            ^~
main.c:83:30: error: invalid type argument of '->' (have 'int')
   83 |   while(tmp->next!=nil && tmp->key!=x){
      |                              ^~
main.c:84:12: error: invalid type argument of '->' (have 'int')
   84 |     tmp=tmp->next;
      |            ^~
main.c: In function 'deleteFirst':
main.c:91:3: error: unknown type name 'NodePointer'
   91 |   NodePointer delnode;
      |   ^~~~~~~~~~~
main.c:92:14: error: invalid type argument of '->' (have 'int')
   92 |   delnode=nil->next;
      |              ^~
main.c:94:13: error: invalid type argument of '->' (have 'int')
   94 |   if(delnode->next==nil){
      |             ^~
main.c:95:8: error: invalid type argument of '->' (have 'int')
   95 |     nil->next=nil;
      |        ^~
main.c:96:8: error: invalid type argument of '->' (have 'int')
   96 |     nil->prev=nil;
      |        ^~
main.c:97:5: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   97 |     free(delnode);
      |     ^~~~
main.c:97:5: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:97:5: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:97:5: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:97:10: error: passing argument 1 of 'free' makes pointer from integer without a cast [-Wint-conversion]
   97 |     free(delnode);
      |          ^~~~~~~
      |          |
      |          int
main.c:97:10: note: expected 'void *' but argument is of type 'int'
main.c:100:8: error: invalid type argument of '->' (have 'int')
  100 |     nil->next=delnode->next;
      |        ^~
main.c:100:22: error: invalid type argument of '->' (have 'int')
  100 |     nil->next=delnode->next;
      |                      ^~
main.c:101:12: error: invalid type argument of '->' (have 'int')
  101 |     delnode->next->prev=delnode->prev;
      |            ^~
main.c:101:32: error: invalid type argument of '->' (have 'int')
  101 |     delnode->next->prev=delnode->prev;
      |                                ^~
main.c:102:5: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
  102 |     free(delnode);
      |     ^~~~
main.c:102:5: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:102:10: error: passing argument 1 of 'free' makes pointer from integer without a cast [-Wint-conversion]
  102 |     free(delnode);
      |          ^~~~~~~
      |          |
      |          int
main.c:102:10: note: expected 'void *' but argument is of type 'int'
main.c: In function 'deleteLast':
main.c:110:3: error: unknown type name 'NodePointer'
  110 |   NodePointer delnode;
      |   ^~~~~~~~~~~
main.c:112:18: error: invalid type argument of '->' (have 'int')
  112 |   for(delnode=nil->next;delnode->next!=nil;delnode=delnode->next);
      |                  ^~
main.c:112:32: error: invalid type argument of '->' (have 'int')
  112 |   for(delnode=nil->next;delnode->next!=nil;delnode=delnode->next);
      |                                ^~
main.c:112:59: error: invalid type argument of '->' (have 'int')
  112 |   for(delnode=nil->next;delnode->next!=nil;delnode=delnode->next);
      |                                                           ^~
main.c:114:10: error: invalid type argument of '->' (have 'int')
  114 |   delnode->prev->next=nil;
      |          ^~
main.c:115:6: error: invalid type argument of '->' (have 'int')
  115 |   nil->prev=delnode->prev;
      |      ^~
main.c:115:20: error: invalid type argument of '->' (have 'int')
  115 |   nil->pre