#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 AND && //I like booleans and find them much easier to read. 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); //Radius of a circle with a given circumference float AreaFromCirc(float); //Area of a circle with a given circumference float CircFromArea(float); //Circumference of a circle with a given area int main(void) { int x; //I'd like it to be a habit to separate variable declarations from statements. Main: //I know it is bad practice to use labels, but I don't know how else to do this. I will learn one day! 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 (1 <= x AND x <= 6) { /* Here is an interesting little guy. switch. Syntax is the following: (declare variable, MUST BE INT) (display menu with several options) (prompt input for same variable) switch(variable) { case x: (colon is needed) { code goes here ends with break; } case x + 1... ... default: [this handles erroneous input or inputs that are out of the scope of the menu (in case someone is a smartass. LOOKING AT YOU ADRIAN.) ] { some sort of error handling and a throwback to the original menu } } rest of program */ switch(x) { case 1: { float radius; float Area; printf("\nInput radius: "); scanf("%f",&radius); //scanf needs a %f now since radius is a floating point number. Oh! reminder. it is &variable because you are writing a value to the address of the variable. Area = AoC(radius); printf("The area is: %f", Area); break; } case 2: { float radius; float Circ; printf("\nInput radius: "); scanf("%f", &radius); Circ = CoC(radius); printf("The circumference is: %f", Circ); break; } case 3: { float Area; float RfA; //radius of a circle with a given area printf("\nInput Area: "); scanf("%f", &Area); RfA = RadiusFromArea(Area); printf("The radius is: %f", RfA); break; } case 4: { float Circ; //Circumference float RfC; //Radius of a circle with a given circumference printf("\nInput Circumference: "); scanf("%f", &Circ); RfC = RadiusFromCirc(Circ); printf("The radius is: %f", RfC); break; } case 5: { float Area; float CfA; //Circumference of a circle with a given area printf("\nInput Area: "); scanf("%f", &Area); CfA = CircFromArea(Area); printf("The circumference is: %f", CfA); break; } case 6: { float Circ; //Circumference float AfC; //Area of circle printf("\nInput Circumference: "); scanf("%f", &Circ); AfC = AreaFromCirc(Circ); printf("The area is: %f", AfC); break; } default: { printf("\nThat isn't a fucking menu option you nigger.\n\n"); //WELL IT ISN'T. x = 0; goto Main; break; } } return 0; } else { printf("\nInvalid menu option. Don't fuck with me."); goto Main; } } //Tharr be functions ahead. This is where I define them I guess float AoC(float radius) //Area of circle { return pi*radius*radius; } float CoC(float radius) //Circumference of circle { 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)); }