Tuesday, 9 December 2014

C Program to find Area and Perimeter of a circle

Program to find Area & Perimeter of a circle
//#define pi=3.14;
#include<stdio.h>
main()
{
float l,b,r,arear,perr,areac,perc,pi=3.14;
printf("enter length, breadth of rectangle\n");
scanf("%f%f",&l,&b);
arear=(l*b);
perr=2*(l+b);
printf("area=%f perimeter=%f\n",arear,perr);
printf("enter radius of circle\n");
scanf("%f",&r);
areac=(pi*r*r);
perc=2*pi*r;
printf("area of circle=%f perimeter of circle=%f\n",areac,perc);
}
OutPut:
enter length, breadth of rectangle
1
2
area=2.000000 perimeter=6.000000
enter radius of circle
4
area of circle=50.240002 perimeter of circle=25.120001