#include #include //I had to google to learn about this header. It handles basic math operations.. I think. I'll try it. //This will be my attempt at making a menu-based program. //It will resemble a TI-BASIC program because that's all I know. //Here we go! #define OR | //I like booleans, fuck you. Instead of using |, I will use the more plain-language OR. const float pi = 3.14159265; float AoC(float); //Area of a circle with a given radius float CoC(float); //Circumference of a circle with a given radius float RadiusFromArea(float); //Self explanatory float RadiusFromCirc(float); float AreaFromCirc(float); float CircFromArea(float); int main(void) { int x; float radius; Main: printf("This program will try to solve for various parameters of \n of a circle depending on what is known. \n\n1. Radius is known, calculate Area. \n2. Radius is known, calculate Circumference.\n"); printf("3. Area is known, solve for Radius. \n4. Circumference is known, solve for Radius. \n5. Area is known, solve for circumference. \n6. Circumference is known, solve for Area.\nMenu choice: "); scanf("%d", &x); if (x == 1) { float Area; printf("\nInput radius: "); scanf("%f",&radius); Area = AoC(radius); printf("The area is: %f", Area); return 0; } else if (x == 2) { float Circ; printf("\nInput radius: "); scanf("%f", &radius); Circ = CoC(radius); printf("The circumference is: %f", Circ); return 0; } else if (x == 3) { float Area; float RfA; printf("\nInput Area: "); scanf("%f", &Area); RfA = RadiusFromArea(Area); printf("The radius is: %f", RfA); return 0; } else if (x == 4) { float Circ; float RfC; printf("\nInput Circumference: "); scanf("%f", &Circ); RfC = RadiusFromCirc(Circ); printf("The radius is: %f", RfC); return 0; } else if (x == 5) { float Area; float CfA; printf("\nInput Area: "); scanf("%f", &Area); CfA = CircFromArea(Area); printf("The circumference is: %f", CfA); return 0; } else if (x == 6) { float Circ; float AfC; printf("\nInput Circumference: "); scanf("%f", &Circ); AfC = AreaFromCirc(Circ); printf("The area is: %f", AfC); return 0; } else if (x != 1 OR x != 2 OR x != 3 OR x != 4 OR x != 5 OR x != 6) { printf("\nThat isn't a fucking menu option you nigger.\n\n"); goto Main; return 0; } } //Tharr be functions ahead. Lots. float AoC(float radius) { return pi*radius*radius; } float CoC(float radius) { return 2*pi*radius; } //This next one is what required the math header. Square root, apparently, is not included in stdio.h. No big deal. //For reference, the syntax is sqrt(x), where x is the number you wish to find the square root of float RadiusFromArea(float Area) { return sqrt(Area/pi); } float RadiusFromCirc(float Circ) { return (Circ/(2*pi)); } //I learned how to use another function! pow(x, y) = x raised to the y power. The more you know! float AreaFromCirc(float Circ) { return pow(pi*(Circ/(2*pi)), 2); } //Another instance of the sqrt. function. float CircFromArea(float Area) { return (2*(sqrt(Area/pi)*pi)); }