Index « Previous Next »

Question

Write a program that prompts the user to input the radius of a circle and outputs the area and circumference of the circle. The formula is

Area = pi x radius2
Circumference = 2 x pi x radius

Source Code

#include <stdio.h>

int main()
{
    float radius, area, circumference;

    printf("Enter the radius of the circle :");
    scanf("%f", &radius);

    area = 3.14 * radius * radius;
    circumference = 2 * 3.14 * radius;

    printf("\nThe area of the circle is %0.2f", area);
    printf("\nThe circumference of the circle is %0.2f", circumference);

    return 0;
}

Output

Enter the radius of the circle :3.4

The area of the circle is 36.30
The circumference of the circle is 21.35