- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Area of the biggest possible rhombus that can be inscribed in a rectangle in C Program?
Here we will see one problem, where one rectangle is given. We have to find the area of largest rhombus that can be inscribed in the rectangle. The diagram will be look like below −
The length of the rectangle is ‘l’ and breadth is ‘b’ So the area of the rhombus is −
Source Code
#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); }
Output
Area : 70
Advertisements