Area of the biggest possible rhombus that can be inscribed in a rectangle in C?

CServer Side ProgrammingProgramming

A rhombus inscribed in a rectangle touches the sides of the rectangle so by this we can infer that the diagonals of the largest inscribed rhombus are equal to the length and breadth of the rectangle.

If we have the length(l) and breadth(b) of the rectangle, the length of the diagonal of the largest rhombus inscribed inside it is d1 = l and d2 = b.

The area of a rhombus is given by the formula,

Area = (d1*d2)/2

Putting the values of d1 and d2. We get,

Area = (l*b)/2

Using this formula we can create a program that calculates the area of biggest rhombus that can be inscribed in a rectangle,

Example

 Live Demo

#include <stdio.h>
int main() {
   float l = 16, b = 6;
   float area = (l*b)/2;
   printf("The area of rhombus inscribed in a rectangle of length %f and breadth %f is %f", l,b,area);
   return 0;
}

Output

The area of rhombus inscribed in a rectangle of length 15 and breadth 12 is 90.
raja
Published on 03-Oct-2019 13:12:58
Advertisements