Language: C

int stack[MAX];

int main()
{
  int x, a, b;
  char s[100];
  while(scanf("%s", s) != EOF) {
    if(s[0] == '+') {
      push(pop()+pop());
    }
    else if(s[0] == '-') {
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(s[0] == '*') {
      push(pop()*pop());
    }
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n", pop());
  return 0;
}
  
int isempty(void)
{
  return top == 0;
}
  
int isfull(void)
{
  return top >= MAX-1;
}

void push(int x)
{
  if(isfull()) {
    fprintf(stderr, "エラー（オーバーフロー）\n");
    exit(1);
  }
  top++;
  stack[top] = x;
}

int pop(void)
{
  if(isempty()) {
    fprintf(stderr, "エラー（アンダーフロー）\n");
    exit(2);
  }
  top--;
  return stack[top+1];
}

Compiler output:
main.c:1:11: error: 'MAX' undeclared here (not in a function)
    1 | int stack[MAX];
      |           ^~~
main.c: In function 'main':
main.c:7:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    7 |   while(scanf("%s", s) != EOF) {
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int stack[MAX];
main.c:7:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    7 |   while(scanf("%s", s) != EOF) {
      |         ^~~~~
main.c:7:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:7:27: error: 'EOF' undeclared (first use in this function)
    7 |   while(scanf("%s", s) != EOF) {
      |                           ^~~
main.c:7:27: note: 'EOF' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:7:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:7: error: implicit declaration of function 'push' [-Wimplicit-function-declaration]
    9 |       push(pop()+pop());
      |       ^~~~
main.c:9:12: error: implicit declaration of function 'pop' [-Wimplicit-function-declaration]
    9 |       push(pop()+pop());
      |            ^~~
main.c:20:11: error: implicit declaration of function 'atoi' [-Wimplicit-function-declaration]
   20 |       x = atoi(s);
      |           ^~~~
main.c:24:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   24 |   printf("%d\n", pop());
      |   ^~~~~~
main.c:24:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:24:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:24:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'isempty':
main.c:30:10: error: 'top' undeclared (first use in this function)
   30 |   return top == 0;
      |          ^~~
main.c: In function 'isfull':
main.c:35:10: error: 'top' undeclared (first use in this function)
   35 |   return top >= MAX-1;
      |          ^~~
main.c: At top level:
main.c:38:6: warning: conflicting types for 'push'; have 'void(int)'
   38 | void push(int x)
      |      ^~~~
main.c:9:7: note: previous implicit declaration of 'push' with type 'void(int)'
    9 |       push(pop()+pop());
      |       ^~~~
main.c: In function 'push':
main.c:41:5: error: implicit declaration of function 'fprintf' [-Wimplicit-function-declaration]
   41 |     fprintf(stderr, "エラー（オーバーフロー）\n");
      |     ^~~~~~~
main.c:41:5: note: include '<stdio.h>' or provide a declaration of 'fprintf'
main.c:41:5: warning: incompatible implicit declaration of built-in function 'fprintf' [-Wbuiltin-declaration-mismatch]
main.c:41:5: note: include '<stdio.h>' or provide a declaration of 'fprintf'
main.c:41:13: error: 'stderr' undeclared (first use in this function)
   41 |     fprintf(stderr, "エラー（オーバーフロー）\n");
      |             ^~~~~~
main.c:41:13: note: 'stderr' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:42:5: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   42 |     exit(1);
      |     ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
  +++ |+#include <stdlib.h>
    1 | int stack[MAX];
main.c:42:5: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   42 |     exit(1);
      |     ^~~~
main.c:42:5: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:44:3: error: 'top' undeclared (first use in this function)
   44 |   top++;
      |   ^~~
main.c: In function 'pop':
main.c:51:5: warning: incompatible implicit declaration of built-in function 'fprintf' [-Wbuiltin-declaration-mismatch]
   51 |     fprintf(stderr, "エラー（アンダーフロー）\n");
      |     ^~~~~~~
main.c:51:5: note: include '<stdio.h>' or provide a declaration of 'fprintf'
main.c:51:13: error: 'stderr' undeclared (first use in this function)
   51 |     fprintf(stderr, "エラー（アンダーフロー）\n");
      |             ^~~~~~
main.c:51:13: note: 'stderr' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:52:5: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   52 |     exit(2);
      |     ^~~~
main.c:52:5: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:54:3: error: 'top' undeclared (first use in this function); did you mean 'pop'?
   54 |   top--;
      |   ^~~
      |   pop