You are currently viewing WAP to Calculate the perimeter of a rectangle

WAP to Calculate the perimeter of a rectangle

  • Post category:C Programs
Share this to everyone:
#include <stdio.h>

int main()
 {
    float length, width, perimeter;

    // Prompt the user to enter the length and width of the rectangle
    printf("Enter the length of the rectangle: ");
    scanf("%f", &length);
    printf("Enter the width of the rectangle: ");
    scanf("%f", &width);

    // Calculate the perimeter
    perimeter = 2 * (length + width);

    // Print the result
    printf("The perimeter of the rectangle is: %.2f\n", perimeter);

    return 0;
}

Leave a Reply