Created
January 29, 2022 13:57
-
-
Save grebenkov/bdc6733bec0faa62008fcdeaa67637fb to your computer and use it in GitHub Desktop.
Annular section simple implementation in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _USE_MATH_DEFINES | |
#include <math.h> | |
double annsec_MomentOfInertia (double insideD, double outsideD) { | |
return M_PI * (pow(outsideD, 4) - pow(insideD, 4)) / 64; | |
} | |
double annsec_PolarMomentOfInertia (double insideD, double outsideD) { | |
return M_PI * (pow(outsideD, 4) - pow(insideD, 4)) / 32; | |
} | |
double annsec_Area (double insideD, double outsideD) { | |
return M_PI * (pow(outsideD, 2) - pow(insideD, 2)) / 4; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
double annsec_MomentOfInertia (double insideD, double outsideD); | |
double annsec_PolarMomentOfInertia (double insideD, double outsideD); | |
double annsec_Area (double insideD, double outsideD); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "annularsection.h" | |
int main(void) { | |
double insideD, outsideD; | |
double area, moi, polarmoi; | |
printf("Enter inside diameter:\n"); | |
while(scanf("%lf",&insideD) != 1) { | |
printf("Wrong input, please retry:\n"); | |
} | |
printf("Enter outside diameter:\n"); | |
while(scanf("%lf",&outsideD) != 1) { | |
printf("Wrong input, please retry:\n"); | |
} | |
area = annsec_Area(insideD, outsideD); | |
moi = annsec_MomentOfInertia(insideD, outsideD); | |
polarmoi = annsec_PolarMomentOfInertia(insideD, outsideD); | |
printf("Area: %lf\n", area); | |
printf("Moment of inertia: %lf\n", moi); | |
printf("Polar moment of inertia: %lf\n", polarmoi); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment