C Program Accept inner and outer radius of a ring and print the perimeter and area of the ring - IProgramX

Q. Accept inner and outer radius of a ring and print the perimeter and area of the ring.


Program

#include <stdio.h>
int main()
{
    float out_radius,in_radius,area, perimeter;
    printf("Enter inner radius of ring: ");
    scanf("%f",&in_radius);
    printf("Enter outer radius of ring: ");
    scanf("%f",&out_radius);
    perimeter= (2 * 3.14) * (in_radius + out_radius);
    area= 3.14 * ((in_radius * in_radius) + (out_radius * out_radius));
    printf("Area of circle: %f \nPerimeter of circle: %f\n",area,perimeter);
}

Output:

Enter inner radius of ring: 5
Enter outer radius of ring: 6
Area of circle: 191.539993
Perimeter of circle: 69.080002

Post a Comment

1 Comments