Thread: area of a circle

  1. #1
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Arrow area of a circle

    Code:
    /* Program 3: Write a program that reads in the radius of a circle and prints
    			  the circle's diamater, circumference, and area. Use the constant
    			  value 3.1459 fo pie. Do thes calculations in output statements.
    */
    
    #include<stdio.h>
    #include<math.h> // math library
    #define PI 3.1416
    int main(void)
    {
    	float radius, diamater, circumference, area;
    	
    	printf("Please enter the radius of your circle: ");
    	scanf("%f",&radius); //stores variable
    	
    	diamater = radius*2;  // calculates radius
    	circumference = PI*diamater; // calculates circumference
    	area= (PI)*radius*(exp(2)); // to calculate exponent
    	
    	printf("Diameter: %0.2f\n", diamater);
    	printf("Circumference: %0.2f\n", circumference);
    	printf("Circle Area: %0.2f\n", area);
    
    	return 0;
    }
    I have problem with the math function. I want to have this for the formula area= PI*radius^2, so i decided to use the math.h with the exp function but something is wrong. Can some one help me, thanks for your help
    Wise_ron
    One man's constant is another man's variable

  2. #2
    -AppearingOnThis..........
    Join Date
    May 2005
    Location
    Netherlands
    Posts
    44
    Use the pow() function for exponents, although in your case it's probably easiest to simply put radius*radius.

  3. #3
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Thanks

    thanks SirNOt for helping me out.
    Wise_ron
    One man's constant is another man's variable

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circle problem
    By gunghomiller in forum C++ Programming
    Replies: 10
    Last Post: 07-14-2007, 06:40 PM
  2. Need help with switch
    By 3kgt in forum C Programming
    Replies: 2
    Last Post: 02-26-2003, 12:43 PM
  3. Circle Area
    By Zophixan in forum C++ Programming
    Replies: 3
    Last Post: 11-05-2002, 12:50 PM
  4. Whats wrong with my find Circle Area program?[compiles fine]
    By Golden Bunny in forum C++ Programming
    Replies: 22
    Last Post: 06-16-2002, 02:49 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM