Program: 55
Write a c program to find area & perimeter of rectangle and area & circumference of circle | Let Us C Solutions
#include<stdio.h> #include<conio.h> int main() { float l, b, r,ca, cc, ra, rp; //For rectangle printf("Enter the length of rectangle: "); scanf("%f", &l); printf("Enter the breadth of rectangle: "); scanf("%f", &b); //For circle printf("Enter the radius of circle: "); scanf("%f", &r); //Calculate area & perimeter of the rectangle... ra = l * b; //Area of Rectangle = Length x Breadth rp = 2 * (l + b); //Perimeter of Rectangle = 2 x (Length + Breadth) or addition of all sides //Calculate are & circumference of the circle... ca = 3.14 * r * r; //Area of Circle = 2 x Pi x r^2 where Pi = 3.14 cc = 2 * 3.14 * r; //Circumference of Circle = 2 x Pi x r printf("\nThe area of the rectangle: %0.2f", ra); printf("\nThe perimeter of the rectangle: %.2f", rp); printf("\n\nThe area of the circle: %.2f", ca); printf("\nThe circumference of the circle: %.2f", cc); return (0); }
Output:
Enter the length of rectangle: 3
Enter the breadth of rectangle: 2
Enter the radius of circle: 2
The area of the rectangle: 6.00
The perimeter of the rectangle: 10.00
The area of the circle: 12.56
The circumference of the circle: 12.56
Leave a Comment