Subscribe to stev3's Blog        RSS Feed
-----

Finding the area of multiple triangles

Icon Leave Comment
#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
	int count, cycles;
	double area, base[10], height[10];

	cout << "CALCULATE THE AREAS OF TRIANGLES\n\n"; //by stev3
	//Loop how many times?
	cout << "How many triangles do you need to calculate the area of? ";
	cin >> cycles;

	system("cls");

	//Get tri info
	for(count = 1; count <= cycles; count++)
	{
		cout << "\tTriangle no. " << count;

		cout << "\n\nBase: "; cin >> base[count];
		cout << "\nHeight: "; cin >> height[count];
		system("cls");
	}

	//Output
	for(count = 1; count <= cycles; count++)
	{
		area = (base[count] * height[count]) / 2;
		cout << "The Area of the Triangle " << count << ":\t" << area << " square units\n";
	}
	Sleep(4000);
	return 0;
}

0 Comments On This Entry

 

January 2022

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
3031     

Tags

    Recent Entries

    Search My Blog

    3 user(s) viewing

    3 Guests
    0 member(s)
    0 anonymous member(s)

    Test

    test