Thursday, 30 August 2012

The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.


main()
{
 float l,b,r,A_r,P_r,A_c,C_c;
 printf("Enter length and breadth of a rectangle in cm\n");
 scanf("%f%f",&l,&b);
 A_r=l*b;
 P_r=2*(l+b);
 printf("Area of rectangle = %f sq.cm\nPerimeter of rectangle = %f cm\n",A_r,P_r);
 printf("Enter radius of circle in cm\n");
 scanf("%f",&r);
 A_c=22.0/7*r*r;
 C_c=2*22.0/7*r;
 printf("Area of Circle = %f sq.cm\nCircumference of circle = %f cm\n",A_c,C_c);
}

output:-

No comments:

Post a Comment