Question

In: Computer Science

Input No. of triangle : 5 Area of triangle 1: 12.00 Area of triangle 2: 14.14...

Input

No. of triangle : 5

Area of triangle 1: 12.00
Area of triangle 2: 14.14
Area of triangle 3: 14.00
Area of triangle 4: 7.31
Area of triangle 5: 17.32
Area of triangle 6: 14.14

Output:
Triangle 5 has the largest area: 17.32

If i have to save those area (input) into array form. How can i compare and find out which triangle with the largest area.

Solutions

Expert Solution


/*
 *  C++ Program to print the triangle with largest area
 */

#include <iostream>
using namespace std;

#define MAX 10

int main()
{
  float area, areaTriangle[MAX];

  int size;
  cout << "No. of triangle: ";
  cin >> size;

  for (int i = 0; i < size; i++)
  {
    cout << "Area of triangle " << (i+1) << ": ";
    cin >> area;
    areaTriangle[i] = area;
  }

  int maxAreaIndx = 0;

  for (int i  = 0; i < size; i++)
  {
    if (areaTriangle[maxAreaIndx] < areaTriangle[i])
    {
      maxAreaIndx = i;
    }
  }

  cout << "Triangle " << (maxAreaIndx + 1) << " has the largest area: " << areaTriangle[maxAreaIndx] << endl;

  return 0;
}


Related Solutions

45. If the area model for a triangle is A = 1/2 bh, find the area...
45. If the area model for a triangle is A = 1/2 bh, find the area of a triangle with a height of 16 in. and a base of 11 in.? the answer should be A=88 in.squier 43. Using the formula in the previous exercise, find the distance that Susan travels if she is moving at a rate of 60 mi/h for 6.75 h.? the answer should be 405 mi 47. Use the formula from the previous question to find...
You have to write a program that computes the area of a triangle. Input consists of...
You have to write a program that computes the area of a triangle. Input consists of the three points that represent the vertices of the triangle. Points are represented as Cartesian units i.e. X,Y coordinates as in (3,5). Output must be the three points, the three distances between vertices, and the area of the triangle formed by these points. The program must read the coordinates of each point, compute the distances between each pair of them and print these values....
Find the maximum area of a rectangle inscribed in a triangle of area A.(NOTE: the triangle...
Find the maximum area of a rectangle inscribed in a triangle of area A.(NOTE: the triangle need not necessarily be a right angled triangle).
/* calculating area of a circle, calculating area of a rectangle, calculating area of a triangle,...
/* calculating area of a circle, calculating area of a rectangle, calculating area of a triangle, and quit. */ import java.util.Scanner; public class GeoCalculator {    public static void main(String arg[]) { int geoCalc; //number selection of user Scanner get = new Scanner(System.in); //display section. System.out.println("Geometry Calculator"); System.out.println("Please select from the following menu:"); System.out.println("1. Calculate the Area of a Cirlce."); System.out.println("2. Calculate the Area of a Rectangle."); System.out.println("3. Calculate the Area of a Triangle."); System.out.println("4. QUIT"); System.out.println("Please make a selection:...
Triangle Class write a class for triangle input is the length of the 3 edges you...
Triangle Class write a class for triangle input is the length of the 3 edges you can use arccos: math.acos(you_input_here), the output is -pi to pi (in real value) class math class Triangle(): # initialize here def __init__(xxx): # you need to modify this line          # your function angles is to output the 3 angles (in degree) in ascending order def angles():          # is_equilateral outputs True if the triangle is equilateral def is_equilateral():   ...
Create an HTML form with the following: 2 text input fields 1 text area 2 radio...
Create an HTML form with the following: 2 text input fields 1 text area 2 radio buttons or 3 checkboxes 1 button Include labels for fields
Deriving the Area of an Obtuse Triangle You just derived the formula for the area of...
Deriving the Area of an Obtuse Triangle You just derived the formula for the area of an acute triangle using trigonometric ratios. Now extend the idea to finding the area of an obtuse triangle. Part A Draw a line that passes through points A and B. Then draw a line through point C that is perpendicular to line AB . Label the intersection of the perpendicular line AB and as point D. Take a screenshot of your construction, save it,...
write a java program for area and perimeter of right triangle
write a java program for area and perimeter of right triangle
(In Java) Inheritance Shapes: Write 5 Classes: 1) Shapes    2) Triangle 3) Rectangle    4)...
(In Java) Inheritance Shapes: Write 5 Classes: 1) Shapes    2) Triangle 3) Rectangle    4) Circle 5) TestAllShapes (create 1 object of each type and print the Area for each of them.)
In triangle ABC, cevians AD and CF are bisectors. Find area ABC / area AFD if...
In triangle ABC, cevians AD and CF are bisectors. Find area ABC / area AFD if AB = 21, AC = 28, and BC = 20.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT