Filled Under:

C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of Circle

C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle



C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle


In this program I have discussed about the C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle.


Area of a rectangle= Length * Breadth
Perimeter of a rectangle= 2*(length+breadth)

Area of a circle= 3.14* (Radius)^2
Perimeter of a circle= 2* 3.14*radius
-------------------------------------------------------------------------------------------


#include<stdio.h>
void main()
{float rad,length,breadth,area1,area2,peri,circu;
printf("Enter the length and breadth of the rectangle:");
scanf("%f%f",&length,&breadth);
area1=length*breadth;
peri=2*(length+breadth);
printf("The area of the rectangle is %f \n",area1);
printf("THe perimeter of the rectangle is %f \n",peri);
printf("Enter the radius of the circle:");
scanf("%f",&rad);
area2=3.14*(rad*rad);
circu=2*3.14*rad;
printf("The area of the circle is %f \n",area2);
printf("THe circumference of the circle is %f \n",circu);
}

---------------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


0 comments:

Post a Comment

 

Copyright 2020 Programming in C All Right Reserved