#include <stdio.h>
#include <math.h>
// Constants
#define CONCRETE_STRENGTH 25 // MPa
#define STEEL_STRENGTH 415 // MPa
#define FACTOR_LOAD 1.5 // Load factor for safety
// Function prototypes
float calculateEffectiveDepth( float totalDepth) ;
float calculateMomentCapacity( float b, float d, float fck, float fy, float As) ;
int main( ) {
// Variables for beam dimensions
float width, totalDepth, effectiveDepth;
// Input beam dimensions
printf ( "Enter the width of the beam (in mm): " ) ;
printf ( "Enter the total depth of the beam (in mm): " ) ; scanf ( "%f" , & totalDepth
) ;
// Convert to meters for calculation
width /= 1000 ;
totalDepth /= 1000 ;
// Calculate effective depth
effectiveDepth = calculateEffectiveDepth( totalDepth) ;
// Beam dimensions for concrete and steel strength
float b = width; // width of the beam (in meters)
float d = effectiveDepth; // effective depth (in meters)
float fck = CONCRETE_STRENGTH; // Concrete strength (MPa)
float fy = STEEL_STRENGTH; // Steel strength (MPa)
// Example area of steel reinforcement (in mm^2)
float As = 500 ; // mm^2
As /= 1000000 ; // Convert to m^2
// Calculate moment capacity
float momentCapacity = calculateMomentCapacity( b, d, fck, fy, As) ;
// Print results
printf ( "Effective depth of the beam: %.2f meters\n " , effectiveDepth
) ; printf ( "Moment capacity of the beam: %.2f kNm\n " , momentCapacity
) ;
return 0 ;
}
// Function to calculate effective depth (assuming cover is 50 mm)
float calculateEffectiveDepth( float totalDepth) {
const float cover = 0.05 ; // 50 mm cover to steel (in meters)
return totalDepth - cover;
}
// Function to calculate moment capacity
float calculateMomentCapacity( float b, float d, float fck, float fy, float As) {
const float alpha = 0.85 ; // Concrete strength reduction factor
float fc = fck * 1e6 ; // Convert to Pascals
float fyt = fy * 1e6 ; // Convert to Pascals
// Moment capacity formula
float momentCapacity = alpha * fc * b * d * ( d - 0.5 * ( As * fyt) / ( b * alpha * fc) ) ;
momentCapacity /= 1e6 ; // Convert to kNm
return momentCapacity;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovLyBDb25zdGFudHM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