fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. //function prototype
  7. int getLength();
  8. int getWidth();
  9. int getHeight();
  10.  
  11. int vol (int, int, int);
  12. int sA(int, int, int);
  13. void disp(int, int);
  14. int main()
  15. {
  16. //declarations
  17.  
  18. int a = 0;
  19. int b = 0;
  20. int c = 0;
  21. int volume = 0;
  22. int surfaceArea = 0;
  23. //input
  24.  
  25. //calculation
  26.  
  27.  
  28. a = getLength();
  29. b = getWidth();
  30. c = getHeight();
  31. volume = vol(a, b, c);
  32. surfaceArea = sA(a, b, c);
  33.  
  34.  
  35. //output
  36. disp(volume,surfaceArea);
  37. return 0;
  38. }//end main
  39.  
  40. //get length
  41. int getLength()
  42. {
  43.  
  44. int length = 0;
  45. printf("enter length: ");
  46. scanf("%d", &length);
  47. return length;
  48. }
  49.  
  50.  
  51. //get width
  52. int getWidth()
  53. {
  54. int width = 0;
  55. printf("enter width: ");
  56. scanf("%d", &width);
  57. return width;
  58. }
  59.  
  60. int getHeight()
  61. {
  62. int height = 0;
  63. printf("enter height: ");
  64. scanf("%d", &height);
  65. return height;
  66. }
  67. int vol(int length, int width, int height)
  68. {
  69. //return a * b * c
  70. int volume = 0;
  71. volume = (length * width * height);
  72. return volume;
  73.  
  74. }//end volume
  75.  
  76. int sA(int length, int height, int width)
  77. {
  78. //declare variables
  79.  
  80. int wL1 = 0;
  81. int wL2 = 0;
  82. int wL3 = 0;
  83. int surfaceArea = 0;
  84. //breaking up into small portions
  85. wL1 = (width*length);
  86. wL2 = (height*length);
  87. wL3 = (height*width);
  88. surfaceArea = 2*(wL1+wL2+wL3);
  89. //return A=2(wl+hl+hw)
  90. return surfaceArea;
  91.  
  92. }//end surface area
  93.  
  94. void disp(int volume,int surfaceArea)
  95. {
  96. //display results
  97. printf("The Volume of the Rectangular Prism is: %d \n\n", volume );
  98. printf("The Surface Area of the Rectangular prism is: %d", surfaceArea);
  99. }
Success #stdin #stdout 0s 2056KB
stdin
3
2
3
stdout
enter length:  enter width:  enter height:  The Volume of the Rectangular Prism is:   18 

The Surface Area of the Rectangular prism is:  42