Here we will see a problem where a rectangle is given. We must find the area of the largest rhombus that can be inscribed in a rectangle. The figure is as follows -
The length of the rectangle is "l" and the width is "b", so the area of the rhombus is-
#include <iostream> #include <cmath> using namespace std; float area(float l, float b) { if (l < 0 || b < 0) //if the values are negative it is invalid return -1; float area = (l*b) /2; return area; } int main() { float l = 20.0, b = 7; cout << "Area : " << area(l, b); }
Area : 70
The above is the detailed content of Is it possible to write a function in C program that calculates the area of the largest possible rhombus that can be inscribed within a rectangle?. For more information, please follow other related articles on the PHP Chinese website!