fork download
  1.  
  2.  
  3. #include <stdio.h>
  4.  
  5. /* global definition of a function prototype */
  6. /* known to all functions */
  7. int add_two (int, int);
  8. int double_it (int);
  9.  
  10. int main ()
  11. {
  12.  
  13. int doubled; /* the result of a number doubled */
  14. int sum; /* the sum of two numbers */
  15. int val; /* just a number to work with */
  16.  
  17. val = 100;
  18.  
  19. /* call the functions */
  20. /* The function prototypes before help the compiler to */
  21. /* determine the types each function is passed and what it returns */
  22. sum = add_two (val, val*5);
  23. doubled = double_it (val);
  24.  
  25. printf("sum = %i and doubled = %i\n", sum, doubled);
  26.  
  27. return(0);
  28.  
  29. }
  30.  
  31.  
  32. // **************************************************
  33. // Function: add_two
  34. //
  35. // Description: Adds to numbers together and returns
  36. // their sum.
  37. //
  38. // Parameters: num1 - first integer to sum
  39. // num2 - second integer to sum
  40. //
  41. // Returns: result - sum of num1 and num2
  42. //
  43. // ***************************************************
  44.  
  45. int add_two (int num1, int num2)
  46. {
  47.  
  48. int result; /* sum of the two number */
  49.  
  50. result = num1 + num2;
  51.  
  52. return (result);
  53.  
  54. }
  55.  
  56. // **************************************************
  57. // Function: double_it
  58. //
  59. // Description: Adds to numbers together and returns
  60. // their sum.
  61. //
  62. // Parameters: num - number to double
  63. //
  64. // Returns: answer - the value of num doubled
  65. //
  66. // ***************************************************
  67. int double_it (int num)
  68. {
  69.  
  70. int answer; /* num being doubled */
  71.  
  72. answer = num + num;
  73.  
  74. return (answer);
  75. }
  76.  
  77.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
sum = 600 and doubled = 200