Advertisement
touhid_xml

Function in C

Jan 25th, 2016
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. int add();
  3. int sub();
  4. int mul();
  5. int div();
  6. int calculate();
  7. int sum();
  8. int main(void){
  9.     printf("Total is: %d", calculate(999999,200,mul));
  10. return 0;
  11. }
  12.  
  13.  
  14.  
  15. int calculate(int x, int y, int fn()){
  16. return fn(x,y);
  17. }
  18.  
  19.  
  20. int add(int x, int y){
  21.     return x + y;
  22. }
  23.  
  24. int mul(int x, int y){
  25.     return x * y;
  26. }
  27.  
  28. int div(int x, int y){
  29.     return x / y;
  30. }
  31.  
  32. int sub(int x, int y){
  33.     return x - y;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement