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 * (a + b)

perimeter of General triangle: a + b + c

perimeter of Equilateral triangle: 3 * a

perimeter of Right angled triangle: width + height + sqrt(width ^ 2 + height ^ 2)

perimeter of circle: 2 * pi * r

perimeter of rectangle: 2 * (a + b)

perimeter of General triangle: a + b + c

perimeter of Equilateral triangle: 3 * a

perimeter of Right angled triangle: width + height + sqrt(width ^ 2 + height ^ 2)

perimeter of circle: 2 * pi * r

Here is source code of the C Program to Find the perimeter of a circle, rectangle & triangle.The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C Program to Find the Perimeter of a Circle, Rectangle and Triangle`

`*/`

`#include <stdio.h>`

`#include <math.h>`

int main()

`{`

float radius, length, width, a, b, c, 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", &a, &b, &c);

perimeter = a + b + c;

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", &a);

perimeter = 3 * a;

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;

`}`

Output: $ cc pgm32.c -lm $ a.out Perimeter of rectangle --------------------------- Enter width and length of the rectangle : 12 13 Perimeter of rectangle is: 50.000 Perimeter of triangle --------------------------- Enter the size of all sides of the triangle : 12 16 18 Perimeter of triangle is: 46.000 Perimeter of circle --------------------------- Enter the radius of the circle : 10 Perimeter of circle is: 60.000 Perimeter of equilateral triangle --------------------------- Enter any side of the equilateral triangle : 19 34 Perimeter of equilateral triangle is: 57.000 Perimeter of right angled triangle --------------------------- Enter the width and height of the right angled triangle : 5 7 Perimeter of right angled triangle is: 73.366

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.