# Idea for final project

Show 80 post(s) from this thread on one page
Page 4 of 4 First 1234
• 11-15-2012
friedsandwich
Quote:

Originally Posted by std10093
About the char* you said, take a look at the last post here..Read the fgets and atoi part :)

Yes i agree that for your code, using your own defined π is not a problem.However where you have the problem with the M_PI is not at all visible by me, because you did not post the code where you get the relative error :)

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)
• 11-15-2012
std10093
Which means that these functions do not see the definition i would say...If you want to solve it post the code of it :)
• 11-15-2012
friedsandwich
is it really that hard just to scroll through my code and see what im talking about?
Code:

```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; }```
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 command
• 11-15-2012
std10093
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
• 11-15-2012
friedsandwich
Quote:

Originally Posted by std10093
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

That is what i've been saying.... i have the math.h header file included and the M_PI does not work... i cant explain this any more clear than i already have.

"error #2048: Undeclared identifier 'M_PI'."
• 11-15-2012
Matticus
What compiler/OS are you using?
Perhaps try adding this line directly above "#include <math.h>"

Code:

`#define _USE_MATH_DEFINES`
• 11-15-2012
std10093
Quote:

Originally Posted by friedsandwich
That is what i've been saying.... i have the math.h header file included and the M_PI does not work... i cant explain this any more clear than i already have.

"error #2048: Undeclared identifier 'M_PI'."

how to you compile the program? Do you also include -lm?
• 11-15-2012
friedsandwich
I am using Pelles C, I use this because this is the one we use at school.
• 11-15-2012
friedsandwich
Quote:

Originally Posted by Matticus
What compiler/OS are you using?
Perhaps try adding this line directly above "#include <math.h>"

Code:

`#define _USE_MATH_DEFINES`

this worked. :)
• 11-16-2012
rogster001
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
• 11-16-2012
friedsandwich
Quote:

Originally Posted by rogster001
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

hmm... that would be an awesome option, but no idea how to implement that...
Show 80 post(s) from this thread on one page
Page 4 of 4 First 1234