Problem: C program for " The length and breadth of a rectangle and radius of a circle are input through keyboard. write a program to calculate the area and perimeter of a rectangle, and the area and circumference of the circle."
Formulae used:
Area of rectangle + Length x Breadth
Perimeter of rectangle = 2 x ( length + breadth )
Circumference of circle = 2 x PI x radius of circle
Area of circle = PI x radius of circle x radius of circle
C program:
// Program by Shyam Kanth.#include<stdio.h>int main(){float l,b,r,arear,areac,circum,per,pi;pi=3.14;printf("Enter the length of rectangle : ");scanf("%f",&l);printf("Enter the breadth of rectangle : ");scanf("%f",&b);printf("Enter the radius of circle : ");scanf("%f",&r);arear=l*b;per=2*(l+b);areac=pi*r*r;circum=2*pi*r;printf("Area of rectangle is %.2f.\n",arear);printf("Perimeter of rectangle is %.2f.\n",per);printf("Area of circle is %.2f.\n",areac);printf("Circumference of circle is %.2f.\n",circum);return 0;}
- #include < stdio.h > : Header file for input output
- int : Integer data type
- float : Decimal data type
- l,b,r,arear,areac,circum,per,pi : Variable used
- 3.14 : Value of pi
- printf : Function for displaying message
- scanf : Function for taking input
Do comment, if any doubt
Know about me : Shyam Kanth
No comments:
Post a Comment