Program to read the length and bredth of a rectangle and find the perimeter

Source Code:

/*to find the perimeter of a rectangle*/
#include<stdio.h>
int main()
{
    float l, b, p;
    printf("Enter the value of length: ");
    scanf("%f", &l);
    printf("Enter the value of breadth: ");
    scanf("%f", &b);
    p = 2 * (l + b);
    printf("Perimeter of the rectangle is %f", p);
    return 0;
}



Sample Run:

Enter the value of length: 5
Enter the value of breadth: 6
Perimeter of the rectangle is 22

 

No comments:

Post a Comment