You need to indent stuff properly. If you do it you will see your mistakes. Especially with in larger project, indenting is a requirement, not an option.
For now, here you go: (edit: meaning pointing out the mistakes, not indenting it for you )
Code:
#include <stdio.h>
#include <math.h>
// you need this for exit() (though shouldn't actually need exit())
#include <stdlib.h>
int menu(void);
float flength;
float fvolsphere;
float fvolcube;
void changelength(void);
void sphere(void);
void cube(void);
int main(void)
{
printf("Enter the length in meters: /n"); // find our what's wrong here on your own :)
scanf ("%f", &flength);
if (flength < 0.0) { // 1
printf ("Hey! There's no such thing as a negative length!! /n"); // same here
} // 1
// from the end of your code:
exit(0);
}
int menu(void)
{
int choice;
printf("\n\nMenu\n");
printf("1 - Change length value.\n");
printf("2 - Compute and display volume of sphere of this diameter.\n");
printf("3 - Compute and display volume of cube of this side length.\n>");
printf("4 - Quit Program.\n>");
scanf("%d",&choice);
return choice;
}
int choice() { // this was supposed to be a function, right?
int choiceresult; // you cannot reuse a variable name as a function name.
// especially not in the function itself
while ((choiceresult = menu()) != 4) { // 2.
switch (choiceresult) {
case 1: changelength(); break;
case 2: sphere(); break;
case 3: cube(); break;
default: printf("Invalid choice.\n");
}
} // good morning, 2
return 0; // assuming you don't want this in the loop as your intenting implies
}
void changelength(void)
{
printf("Enter the new length, in meters: /n");
scanf ("%f", &flength); // it is scanf, not scan
} // 2 and a half
void sphere(void)
{
fvolsphere = (4.0/3.0)*(M_PI)*(pow(flength,3));
printf("The volume of the sphere is %f \n", fvolsphere);
}
void cube(void)
{
fvolcube = pow(flength,3);
printf("The volume of the cube is %f \n", fvolcube);
}
// now I see, you were trying to nest those functions in main(). Thats not possible.
// moving this up
//exit (0);
//}