## C Program To Find Perimeter of Rectangle

Learn How To Find Perimeter of Rectangle in C Programming Language. We have different variants that includes Pointers and Functions.

#### Formula To Calculate Perimeter of Rectangle

**Perimeter of Rectangle = 2 * (length * breadth)**

**Must Read: C Program To Print Current Time and Date**

#### Method 1: Find Perimeter of Rectangle in C Programming using Function

#include<stdio.h> int perimeter(int l, int b) { int result = 2*(l + b); return result; } int main() { int length, breadth; printf("\nEnter Length of Rectangle:\t"); scanf("%d", &length); printf("\nEnter Breadth of Rectangle:\t"); scanf("%d", &breadth); printf("\nLength: %d\n", length); printf("\nBreadth: %d\n", breadth); printf("\nPerimeter of Rectangle: %d\n", perimeter(length,breadth)); return 0; }

**Must Read: Display Fibonacci Series in C Programming**

#### Method 2: C Program To Calculate Perimeter of Rectangle without Function

#include<stdio.h> int main() { int length, breadth, perimeter; printf("\nEnter Length of Rectangle:\t"); scanf("%d", &length); printf("\nEnter Breadth of Rectangle:\t"); scanf("%d", &breadth); perimeter = 2*(length + breadth); printf("\nLength: %d\n", length); printf("\nBreadth: %d\n", breadth); printf("\nPerimeter of Rectangle: %d\n", perimeter); return 0; }

**Must Read: C Program To Develop Simple Calculator Application**

#### Method 3: C Program For Calculating Perimeter of Rectangle using Pointer

#include<stdio.h> #include<stdlib.h> int main() { int *length, *breadth, *perimeter; length = (int*)malloc(sizeof(int)); breadth = (int*)malloc(sizeof(int)); perimeter = (int*)malloc(sizeof(int)); printf("\nEnter Length of Rectangle:\t"); scanf("%d", length); printf("\nEnter Breadth of Rectangle:\t"); scanf("%d", breadth); *perimeter = 2*(*length + *breadth); printf("\nLength: %d\n", *length); printf("\nBreadth: %d\n", *breadth); printf("\nPerimeter of Rectangle: %d\n", *perimeter); return 0; }

**Must Read: C Program To Find Distance Between Two Co – ordinate Points**

#### Output

If you have any compilation errors or doubts in this C Program to Find Perimeter of Rectangle, let us know about it in the Comment Section below.

The pointer method to find perimeter of rectangle is really amazing. Thanks.

This is really an easy code. I dont know why i couldnt do it.