fork download
  1. #include <stdio.h>
  2.  
  3. struct operation {
  4. char *funcname;
  5. char *op;
  6. } ;
  7.  
  8. int main(void) {
  9. struct operation oparr[4] =
  10. {
  11. {"plus" , "+"},
  12. {"minus" , "-"},
  13. {"multiply", "*"},
  14. {"divide" , "/"}
  15. };
  16.  
  17. for (struct operation *oparr_ptr = oparr; oparr_ptr < &oparr[4]; oparr_ptr++)
  18. (
  19. "int %s (int a, int b) {return a %s b};\n\n",
  20. oparr_ptr->funcname, oparr_ptr->op
  21. );
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
int plus (int a, int b) {return a + b};

int minus (int a, int b) {return a - b};

int multiply (int a, int b) {return a * b};

int divide (int a, int b) {return a / b};