C Programming Code Examples C > Mathematics Code Examples Program to Find the Perimeter of a Circle, Rectangle and Triangle Program to Find the Perimeter of a Circle, Rectangle and Triangle This C Program calculates the perimeter of a circle, rectangle and triangle. This program is used to find the perimeter of a circle, rectangle and triangle. The formula used in this program are perimeter of rectangle: 2 * (x + y) perimeter of General triangle: x + y + z perimeter of Equilateral triangle: 3 * x perimeter of Right angled triangle: width + height + sqrt(width ^ 2 + height ^ 2) perimeter of circle: 2 * pi * r #include <stdio.h> #include <math.h> int main() { float radius, length, width, x, y, z, height; int n; float perimeter; //Perimeter of rectangle printf(" \n Perimeter of rectangle \n"); printf("---------------------------\n"); printf("\n Enter width and length of the rectangle : "); scanf("%f%f", &width,& length); perimeter = 2 * (width + length); printf("Perimeter of rectangle is: %.3f", perimeter); //Perimeter of triangle printf("\n Perimeter of triangle n"); printf("---------------------------n"); printf("\n Enter the size of all sides of the triangle : "); scanf("%f%f%f", &x, &y, &z); perimeter = x + y + z; printf("Perimeter of triangle is: %.3f", perimeter); //Perimeter of circle printf(" \n Perimeter of circle \n"); printf("---------------------------\n"); printf("\n Enter the radius of the circle : "); scanf("%f", &radius); perimeter = 2 * (22 / 7) * radius; printf("Perimeter of circle is: %.3f", perimeter); //Perimeter of equilateral triangle printf(" \n Perimeter of equilateral triangle \n"); printf("---------------------------\n"); printf("\n Enter any side of the equilateral triangle : "); scanf("%f", &x); perimeter = 3 * x; printf("Perimeter of equilateral triangle is: %.3f", perimeter); //Perimeter of right angled triangle printf(" \n Perimeter of right angled triangle \n"); printf("---------------------------\n"); printf("\n Enter the width and height of the right angled triangle : "); scanf("%f%f", &width, &height); perimeter = width + height + sqrt(width * width + height * height); printf("Perimeter of right angled triangle is: %.3f", perimeter); return 0; }