C Program to Calculate the Perimeter and Area of Rong
C Program to Calculate Area and Perimeter of Ring
Area of Ring Formula to find area of ring: A=π(R2﹣r2) Perimeter of Ring Formula to find perimeter of ring: Perimeter = 2π(R+r)
This C code accepts the inner and outer radius and finds the area and perimeter of ring.
/* Aim: To calculate the perimeter and area of ring */
#include<stdio.h>
int main()
{
float area,a,b,p;
printf("\n Enter inner radius of ring: ");
scanf("%f",&a);
printf("\n Enter outer radius of ring: ");
scanf("%f",&b);
p=2*3.142*(a+b);
area=3.142*(b*b-a*a);
printf("\n The Perimeter of ring is : %f",p);
printf("\n \n The area of ring is : %f \n \n",area);
return 0;
}
Output:
Enter inner radius of ring: 12 Enter outer radius of ring: 16 The Perimeter of ring is : 175.951996 The area of ring is : 351.903992