fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. // Constants
  5. #define CONCRETE_STRENGTH 25 // MPa
  6. #define STEEL_STRENGTH 415 // MPa
  7. #define FACTOR_LOAD 1.5 // Load factor for safety
  8.  
  9. // Function prototypes
  10. float calculateEffectiveDepth(float totalDepth);
  11. float calculateMomentCapacity(float b, float d, float fck, float fy, float As);
  12.  
  13. int main() {
  14. // Variables for beam dimensions
  15. float width, totalDepth, effectiveDepth;
  16.  
  17. // Input beam dimensions
  18. printf("Enter the width of the beam (in mm): ");
  19. scanf("%f", &width);
  20.  
  21. printf("Enter the total depth of the beam (in mm): ");
  22. scanf("%f", &totalDepth);
  23.  
  24. // Convert to meters for calculation
  25. width /= 1000;
  26. totalDepth /= 1000;
  27.  
  28. // Calculate effective depth
  29. effectiveDepth = calculateEffectiveDepth(totalDepth);
  30.  
  31. // Beam dimensions for concrete and steel strength
  32. float b = width; // width of the beam (in meters)
  33. float d = effectiveDepth; // effective depth (in meters)
  34. float fck = CONCRETE_STRENGTH; // Concrete strength (MPa)
  35. float fy = STEEL_STRENGTH; // Steel strength (MPa)
  36.  
  37. // Example area of steel reinforcement (in mm^2)
  38. float As = 500; // mm^2
  39. As /= 1000000; // Convert to m^2
  40.  
  41. // Calculate moment capacity
  42. float momentCapacity = calculateMomentCapacity(b, d, fck, fy, As);
  43.  
  44. // Print results
  45. printf("Effective depth of the beam: %.2f meters\n", effectiveDepth);
  46. printf("Moment capacity of the beam: %.2f kNm\n", momentCapacity);
  47.  
  48. return 0;
  49. }
  50.  
  51. // Function to calculate effective depth (assuming cover is 50 mm)
  52. float calculateEffectiveDepth(float totalDepth) {
  53. const float cover = 0.05; // 50 mm cover to steel (in meters)
  54. return totalDepth - cover;
  55. }
  56.  
  57. // Function to calculate moment capacity
  58. float calculateMomentCapacity(float b, float d, float fck, float fy, float As) {
  59. const float alpha = 0.85; // Concrete strength reduction factor
  60. float fc = fck * 1e6; // Convert to Pascals
  61. float fyt = fy * 1e6; // Convert to Pascals
  62.  
  63. // Moment capacity formula
  64. float momentCapacity = alpha * fc * b * d * (d - 0.5 * (As * fyt) / (b * alpha * fc));
  65. momentCapacity /= 1e6; // Convert to kNm
  66. return momentCapacity;
  67. }
  68.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Enter the width of the beam (in mm): Enter the total depth of the beam (in mm): Effective depth of the beam: -0.05 meters
Moment capacity of the beam: 0.01 kNm