# Thread: Idea for final project

1. 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)

2. Which means that these functions do not see the definition i would say...If you want to solve it post the code of it

3. 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: ");
{
printf("ERROR!! Distance must be a positive number\n\n");
printf("Enter the radius: ");
}
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("ERROR!! Distance must be a positive number\n\n");
}
{
printf("ERROR!! Distance must be a positive number\n\n");
}
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

4. 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

5. 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'."

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

Code:
`#define _USE_MATH_DEFINES`

7. 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?

8. I am using Pelles C, I use this because this is the one we use at school.

9. 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.

10. 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. 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...

Popular pages Recent additions