C Program for Circumference of a Parallelogram

We are given the sides of a parallelogram and the task is to calculate the circumference of the parallelogram with its given sides and display the result.

What is a Parallelogram?

A parallelogram is a type of quadrilateral which has −

  • Opposite sides parallel and equal
  • Opposite angles equal
  • Diagonals bisect each other

In the below figure, 'a' and 'b' are the sides of a parallelogram where parallel sides are shown.

a a b b

Syntax

Circumference = 2 * (a + b)

Circumference of a parallelogram is defined as

Circumference of Parallelogram = 2(a + b) = 2 * a + 2 * b

Where 'a' and 'b' are the lengths of adjacent sides of the parallelogram.

Example 1: Basic Circumference Calculation

#include <stdio.h>

// Function to calculate circumference of parallelogram
float circumference(float a, float b) {
    return ((2 * a) + (2 * b));
}

int main() {
    float a = 23, b = 12;
    printf("Side a = %.2f, Side b = %.2f
", a, b); printf("Circumference of parallelogram is: %.2f
", circumference(a, b)); return 0; }
Side a = 23.00, Side b = 12.00
Circumference of parallelogram is: 70.00

Example 2: User Input for Parallelogram Sides

#include <stdio.h>

float calculateCircumference(float side1, float side2) {
    return 2 * (side1 + side2);
}

int main() {
    float a = 16.2, b = 24.0;
    
    printf("Enter values for demonstration:
"); printf("Side a = %.1f
", a); printf("Side b = %.1f
", b); float result = calculateCircumference(a, b); printf("Circumference of parallelogram = 2 * (%.1f + %.1f) = %.1f
", a, b, result); return 0; }
Enter values for demonstration:
Side a = 16.2
Side b = 24.0
Circumference of parallelogram = 2 * (16.2 + 24.0) = 80.4

Algorithm

START
Step 1 ? Declare function to calculate circumference of parallelogram
         float circumference(float a, float b)
         return (2 * (a + b))
Step 2 ? In main()
         Declare float a, b (sides of parallelogram)
         Call circumference(a, b)
         Print the result
STOP

Key Points

  • A parallelogram has two pairs of equal opposite sides
  • The circumference formula is 2 * (a + b) where a and b are adjacent sides
  • The result represents the total distance around the parallelogram

Conclusion

Calculating the circumference of a parallelogram in C is straightforward using the formula 2 * (a + b). This approach works for any parallelogram regardless of its angles, as long as we know the lengths of two adjacent sides.

Updated on: 2026-03-15T12:26:14+05:30

243 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements