Public paste
pwnd
By: 0_C001 | Date: Sep 11 2006 16:58 | Format: None | Expires: never | Size: 2.96 KB | Hits: 1436

  1. #ifndef IN2CM_H
  2. #define IN2CM_H
  3. #include <stdio.h>
  4. float convert(int in);
  5. int get(int i);
  6. void output(float result);
  7. #endif
  8.  
  9. /***************** END OF HEADER ***********************/
  10.  
  11.  
  12.  
  13. #include "in2cm.h"
  14.  
  15. int main(void)
  16. {
  17.         int inches = 0;
  18.         float centimeters = 0;
  19.  
  20.         inches = get(inches);
  21.         centimeters = convert(inches);
  22.         output(centimeters);
  23.  
  24.         return (0);
  25. }
  26.  
  27. /*************************************
  28. * FUNCTION:  get(int i)              *
  29. * This function accepts input from   *
  30. * stdin and returns the data to the  *
  31. * main().                            *
  32. *************************************/
  33. int get(int i)
  34. {
  35.     printf("nEnter your height in inches > ");
  36.     scanf("%d", &i);
  37.     return(i);
  38. }
  39.  
  40. /*************************************
  41. * FUNCTION:  convert(int in)         *
  42. * This function converts the number  *
  43. * of inches to centimeters and then  *
  44. * passes the result to the output(). *
  45. *************************************/
  46. float convert(int in)
  47. {
  48.     float cm = in * 2.54;
  49.     return (cm);
  50. }
  51.  
  52. /*************************************
  53. * FUNCTION:  output(float result)    *
  54. * This function formats the data     *
  55. * from the convert() and displays    *
  56. * the resulting value.               *
  57. *************************************/
  58. void output(float result)
  59. {
  60.     printf("nYou are %.2f centimeters tall!nn", result);
  61. }
  62.  
  63.  
  64.  
  65. #ifndef IN2CM_H
  66. #define IN2CM_H
  67. #include <stdio.h>
  68. float convert(int in);
  69. int get(int i);
  70. void output(float result);
  71. #endif
  72.  
  73. /***************** END OF HEADER ***********************/
  74.  
  75.  
  76.  
  77. #include "in2cm.h"
  78.  
  79. int main(void)
  80. {
  81.         int inches = 0;
  82.         float centimeters = 0;
  83.  
  84.         inches = get(inches);
  85.         centimeters = convert(inches);
  86.         output(centimeters);
  87.  
  88.         return (0);
  89. }
  90.  
  91. /*************************************
  92. * FUNCTION:  get(int i)              *
  93. * This function accepts input from   *
  94. * stdin and returns the data to the  *
  95. * main().                            *
  96. *************************************/
  97. int get(int i)
  98. {
  99.     printf("nEnter your height in inches > ");
  100.     scanf("%d", &i);
  101.     return(i);
  102. }
  103.  
  104. /*************************************
  105. * FUNCTION:  convert(int in)         *
  106. * This function converts the number  *
  107. * of inches to centimeters and then  *
  108. * passes the result to the output(). *
  109. *************************************/
  110. float convert(int in)
  111. {
  112.     float cm = in * 2.54;
  113.     return (cm);
  114. }
  115.  
  116. /*************************************
  117. * FUNCTION:  output(float result)    *
  118. * This function formats the data     *
  119. * from the convert() and displays    *
  120. * the resulting value.               *
  121. *************************************/
  122. void output(float result)
  123. {
  124.     printf("nYou are %.2f centimeters tall!nn", result);
  125. }
  126.  
  127.  
  128.  
  129. /*********************** OUTPUT *************************
  130.  
  131.  
  132.  
  133.   Enter your height in inches > 67  
  134.   You are 170.18 centimeters tall!  
  135.  
  136.  
  137. *********************************************************/
  138.