Language: C


  for(i=0;i<n;i++){
    scanf("%s",a[i]);
    if(strcmp(a[i],"insert")==0){
      scanf("%d",&b);
      insert(b);
    }
    else if(strcmp(a[i],"delete")==0){
      scanf("%d",&b);
      //  printf("\nb %d\n",b);
      delete(b);	
    }
    else if(strcmp(a[i],"deleteLast")==0){
      deleteLast();	
    }
    else if(strcmp(a[i],"deleteFirst")==0){
      deleteFirst();	
    }
  }
  i=j-1;
  while(1){
    if(Q[i].flag!=1){
      printf("%d",Q[i].val);
      break;
    }
    i--;
  }
  i--;
  for(;i>0;i--){
    if(Q[i].flag!=1)printf(" %d",Q[i].val);
  }
  printf("\n");
  return 0;
}
void insert(int b){
  Q[j].val = b;
  Q[j].flag = 0;
  j++;
}
void delete(int b){
  int i;
  for(i=j-1;i>=0;i--){

    if(Q[i].val==b && Q[i].flag!=1){
      Q[i].flag=1;
      break;
    }
  }
}
void deleteFirst(){
  int i;

  for(i=j-1;i>=0;i--){
    if(Q[i].flag!=1){
      Q[i].flag=1;
      break;
    }
  }
}
void deleteLast(){
  int i;
  for(i=0;i<j;i++){
    if(Q[i].flag!=1){  
      Q[i].flag=1;
      break;
    }
  }
}

Compiler output:
main.c:2:3: error: expected identifier or '(' before 'for'
    2 |   for(i=0;i<n;i++){
      |   ^~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    2 |   for(i=0;i<n;i++){
      |            ^
main.c:2:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    2 |   for(i=0;i<n;i++){
      |                ^~
main.c:20:3: warning: data definition has no type or storage class
   20 |   i=j-1;
      |   ^
main.c:20:3: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:20:5: error: 'j' undeclared here (not in a function)
   20 |   i=j-1;
      |     ^
main.c:21:3: error: expected identifier or '(' before 'while'
   21 |   while(1){
      |   ^~~~~
main.c:28:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before '--' token
   28 |   i--;
      |    ^~
main.c:29:3: error: expected identifier or '(' before 'for'
   29 |   for(;i>0;i--){
      |   ^~~
main.c:29:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>' token
   29 |   for(;i>0;i--){
      |         ^
main.c:29:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '--' token
   29 |   for(;i>0;i--){
      |             ^~
main.c:32:10: error: expected declaration specifiers or '...' before string constant
   32 |   printf("\n");
      |          ^~~~
main.c:33:3: error: expected identifier or '(' before 'return'
   33 |   return 0;
      |   ^~~~~~
main.c:34:1: error: expected identifier or '(' before '}' token
   34 | }
      | ^
main.c: In function 'insert':
main.c:36:3: error: 'Q' undeclared (first use in this function)
   36 |   Q[j].val = b;
      |   ^
main.c:36:3: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'delete':
main.c:44:8: error: 'Q' undeclared (first use in this function)
   44 |     if(Q[i].val==b && Q[i].flag!=1){
      |        ^
main.c: In function 'deleteFirst':
main.c:54:8: error: 'Q' undeclared (first use in this function)
   54 |     if(Q[i].flag!=1){
      |        ^
main.c: In function 'deleteLast':
main.c:63:8: error: 'Q' undeclared (first use in this function)
   63 |     if(Q[i].flag!=1){
      |        ^