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