Like Tree7Likes

Idea for final project

This is a discussion on Idea for final project within the General Discussions forums, part of the Community Boards category; Originally Posted by std10093 About the char* you said, take a look at the last post here ..Read the fgets ...

  1. #46
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    Quote Originally Posted by std10093 View Post
    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. #47
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675
    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. #48
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    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
    Last edited by friedsandwich; 11-15-2012 at 02:14 PM.

  4. #49
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675
    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. #50
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    Quote Originally Posted by std10093 View Post
    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'."
    Last edited by friedsandwich; 11-15-2012 at 02:22 PM.

  6. #51
    Registered User
    Join Date
    Jun 2011
    Posts
    2,265
    What compiler/OS are you using?
    Perhaps try adding this line directly above "#include <math.h>"

    Code:
    #define _USE_MATH_DEFINES
    stahta01 likes this.

  7. #52
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,675
    Quote Originally Posted by friedsandwich View Post
    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. #53
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    I am using Pelles C, I use this because this is the one we use at school.

  9. #54
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    Quote Originally Posted by Matticus View Post
    What compiler/OS are you using?
    Perhaps try adding this line directly above "#include <math.h>"

    Code:
    #define _USE_MATH_DEFINES
    this worked.

  10. #55
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    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
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  11. #56
    Registered User
    Join Date
    Nov 2012
    Posts
    35
    Quote Originally Posted by rogster001 View Post
    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...

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ideas for a final project
    By doubleanti in forum General Discussions
    Replies: 11
    Last Post: 09-09-2012, 08:00 AM
  2. Must be final project time again....
    By VirtualAce in forum General Discussions
    Replies: 21
    Last Post: 05-19-2010, 07:04 PM
  3. Final Project for HS, any ideas?
    By Conneticut#88 in forum C++ Programming
    Replies: 13
    Last Post: 05-24-2006, 09:22 PM
  4. Final year project
    By afisher in forum C# Programming
    Replies: 3
    Last Post: 07-04-2005, 08:15 AM
  5. Final year project
    By khpuce in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 10-10-2003, 07:04 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21