J2D50

              :-/

# E/A

  $ gcc rcl.c -o rcl

file rcl.c

  #include <time.h>
  #include <stdio.h>
  #include <stdlib.h>
  
  #define LEVEL0  0
  #define LEVEL1  rand()%3

  int other(int arand, int arem) {
    int newrand;
    do {
      newrand=rand()%arem;
    } while(arand==newrand);
    return newrand;
  }

  int main() {
    int   VAL[] = { 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 };
    char* RCL[] = { "R", "C",  "L" };
    char* U[]   = { "K", "nF", "mH" };
    int typ, node;
    int nX, nR = 1, nC = 1, nL = 1;
    
    srand(time(NULL));
   
    node=rand()%5; 
    printf(
      "\nE\t%d\tV\t%d\tKHz\t%d\t%d\n\n", 
      VAL[rand()%10], VAL[rand()%10], node, other(node,5)
    );
    
    for(int n=0; n<10; n++) {
      node=rand()%5;
      typ=LEVEL1;
      switch(typ) {
        case 0: nX = nR++; break;
        case 1: nX = nC++; break;
        case 2: nX = nL++; break;
      }
      printf(
        "%s%d\t%d\t%s\t%d\t%d\n", 
        RCL[typ], nX, VAL[rand()%10], U[typ], node, other(node,5)
      );
    }
    node=rand()%5;
    printf(
      "\nFind Voltage between %d and %d\n\n", 
      node, other(node,5)
    );
    printf(
      "Calculate here: "
      "https://github.com/zupolgec/circuit-simulator\n\n"
    );
    return 0;
  }

EOF


# IT/TA

Read, add operations above, build:

  https://gist.github.com/jandk/1709771
  gcc rpn.c -o rpn
  
Build it.c:

  $ gcc it.c -o it

file it.c

  #include <time.h>
  #include <stdio.h>
  #include <stdlib.h>
  
  #define LEVEL0  0
  #define LEVEL1  rand()%3

  int other(int arand, int arem) {
    int newrand;
    do {
      newrand=rand()%arem;
    } while(arand==newrand);
    return newrand;
  }

  int main() {
    char* CMD[] = { 
      "POP",  "PUSH",  
      "+",    "-",   "*",  "/", "%",  "**", "U-",
      "&",    "|",   "^",  "~", "<<", ">>",
      "&&",   "||",  "!",
      "<",    "<=",  "==", ">=", ">",
      "?:"
    };
    int command;
    
    srand(time(NULL));
    
    printf("\nRPN machine with ACCUMULATOR STACK.\n"
      "Empty stack returns 0.\n\n"
    );
   
    for(int n=0; n<10+rand()%10; n++) {
      command=n?rand()%24:1;
      printf("%02d\t%s", command, CMD[command]);
      if (command) printf("\t%d", rand()%100); 
      printf("\n");
    }
    printf(
      "\nResult is on top of the ACCUMULATOR STACK.\n"
      "Calculate or Save the World:\n"
      "Create simulator, print with POP\n\n"
    );
    return 0;
  }
  
EOF
