I get the error if i delete #define PI 3.14159 and then anywhere i have used my defined PI i replace with M_PI it tells me that M_PI has not been defined as a variable. (obviously in my area equations for circle and ellipses)
Printable View
Which means that these functions do not see the definition i would say...If you want to solve it post the code of it :)
is it really that hard just to scroll through my code and see what im talking about?is the only place i use my pre defined PI, but when i add volumes i will use it more. again, this isn't necessarily a problem though as my code works fine without using the M_PI commandCode:case 5:
{
printf("\nArea Of A Circle\n");
printf("\nEnter the radius: ");
scanf("%lf", &rad1);
while(rad1 <= 0)
{
printf("ERROR!! Distance must be a positive number\n\n");
printf("Enter the radius: ");
scanf("%lf", &rad1);
}
area = (rad1 * rad1) * PI;
printf("The area of a circle with a radius of %.4f is %.4f\n\n", rad1, area);
break;
}
case 6:
{
printf("\nArea Of An Ellipse");
printf("\nEnter radius-1: ");
scanf("%lf", &rad1);
while(rad1 <= 0)
{
printf("ERROR!! Distance must be a positive number\n\n");
printf("Enter radius-1: ");
scanf("%lf", &rad1);
}
printf("\nEnter radius-2: ");
scanf("%lf", &rad2);
while(rad2 <= 0)
{
printf("ERROR!! Distance must be a positive number\n\n");
printf("Enter radius-2: ");
scanf("%lf", &rad2);
}
area = (rad1 * rad2) * PI;
printf("The area of an ellipse with a radius-1 of %.4f and a radius-2 of %.4f is %.4f", rad1, rad2, area);
break;
}
I did scroll down your code :)
M_PI is not a command.It is defined inside the math library.
If you want to use it you have to replace PI with M_PI
What compiler/OS are you using?
Perhaps try adding this line directly above "#include <math.h>"
Code:#define _USE_MATH_DEFINES
I am using Pelles C, I use this because this is the one we use at school.
Maybe on top of the arithmetic your program offers you could add to the functionality with a memory function or 'cancel entry' function in case the user is say adding lots of numbers and makes a mistake with one of the values - you can remove the last one entered