Thread: Passing And Returning Values

  1. #1
    Registered User
    Join Date
    Mar 2003

    Passing And Returning Values

    ************************************************** **
    Here is the question:

    Write a program that prints, in main(), the double-precision area of a circle given that a user's double-precision radius is passed to the function. The formula for calculating a circle's area is

    area = 3.14159 * (radius * radius)
    ************************************************** **
    Here is the code:

    // prints the double precision of the area of the circle
    // where formula is area = 3.14159 * (radius * radius)
    // value is passed to a function

    double radius(double radius); // global variables

    main ()
    double area;
    double radius;

    area = 3.14159 * (radius * radius);

    printf("The double precision area of your circle is %f", area);
    return 0;
    double radius(double radius)
    printf("What is the radius of your circle:");
    scanf(" %.5f", &radius);
    return (radius);

    ************************************************** **

    I get an error message saying that the text in bold is not a function. What am i doing wrong here?

    error C2063: 'radius' : not a function

  2. #2
    Registered User
    Join Date
    Jul 2002
    varibles and functions arent supposed to have the same name

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing / Returning a Boolean (Help)
    By EDB in forum C++ Programming
    Replies: 5
    Last Post: 02-17-2008, 02:56 PM
  2. Passing & Returning Arrays
    By jeffdavis_99 in forum C++ Programming
    Replies: 10
    Last Post: 04-02-2005, 06:44 PM
  3. returning struct and passing as an argument
    By ronin in forum C Programming
    Replies: 4
    Last Post: 06-07-2003, 11:21 AM
  4. Passing & Returning Strings from Functions
    By nisaacs in forum C Programming
    Replies: 1
    Last Post: 01-30-2002, 05:34 AM
  5. returning and passing CArrays
    By swordfish in forum Windows Programming
    Replies: 4
    Last Post: 11-01-2001, 02:59 AM