C Program to find Perimeter of a Rhombus

Write a C Program to find the perimeter of a Rhombus with an example. The math formula to find the Rhombus perimeter is 4 * sides. This C example allows entering rhombus sides and returns the perimeter.

#include <stdio.h>

int main()
{
    float rmside, rmperimeter;
    
    printf("Enter the Rhombus Side = ");
    scanf("%f",&rmside);

    rmperimeter = 4 * rmside;

    printf("The Perimeter of the Rhombus = %.3f\n", rmperimeter);
    
    return 0;
}
C Program to Find Perimeter of a Rhombus 1

In this C Program, we created a function to calculate and return the Rhombus perimeter.

#include <stdio.h>

float rhombusPerimeter(float side)
{
    return 4 * side;
}

int main()
{
    float rmside, rmperimeter;
    
    printf("Enter the Rhombus Side = ");
    scanf("%f",&rmside);

    rmperimeter = rhombusPerimeter(rmside);

    printf("The Perimeter of a Rhombus = %.3f\n", rmperimeter);
    
    return 0;
}
Enter the Rhombus Side = 12
The Perimeter of a Rhombus = 48.000

C Program to Calculate Perimeter of a Rhombus using Pointers.

#include <stdio.h>

void rhombusPerimeter(float *rmside, float *rmperimeter)
{
    *rmperimeter = 4 * (*rmside);
}

int main()
{
    float rmside, rmperimeter;
    
    printf("Enter the Rhombus Side = ");
    scanf("%f",&rmside);

    rhombusPerimeter(&rmside, &rmperimeter);

    printf("The Perimeter of a Rhombus = %.3f\n", rmperimeter); 
    
    return 0;
}
Enter the Rhombus Side = 32
The Perimeter of a Rhombus = 128.000

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.