![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 largest triangle that can be inscribed within a rectangle in C Program?
Suppose one rectangle is given. We know the length L and breadth B of it. We have to find the area of largest triangle that can be inscribed within that rectangle −
The largest triangle will always be the half of the rectangle. So it will be
Example
#include <iostream> #include <cmath> using namespace std; float area(float l, float b) { if (l < 0 || b < 0 ) //if the valuse are negative it is invalid return -1; float area = (l*b)/2; return area; } int main() { float a = 10, b = 8; cout << "Area : " << area(a, b); }
Output
Area : 40
Advertisements