PROGRAMMING | INNOVATIONS | EDUCATION | TECH NEWS

Saturday, June 23, 2018

HOW TO CALCULATE AREA OF EQUILATERAL TRIANGLE IN C/C++





In geometry, an equilateral triangle is a triangle in which all three sides are equal. In the familiar Euclidean geometry, equilateral triangles are also equiangular; that is, all three internal angles are also congruent to each other and are each 60°.

I am going to show you in C and C++ how to find the area of a equilateral triangle... Follow the procedures below:



C CODE

#include<stdio.h>
#include<math.h>
#include<conio.h>
 main()
 {
   int side;
   float area;
   area= sqrt(3) / 4;
   printf("\nEnter the Length of Side : ");
   scanf("%d",&side);
   area = area*side*side;
   printf("Area of Equilateral Triangle %f",area);
   getch();
}

C++ CODE

#include<math.h>
#include<conio.h>
using namespace std;

 int main()
 {
   int side;
   float area;
   area= sqrt(3) / 4;
   cout<<"Enter the Length of Side : ";
   cin>>side;
   area = area*side*side;
   cout<<"Area of Equilateral Triangle is : "<<area;
   getch();
  
   }


WORKING AREA (IDE)
You can use any of the following IDEs to run your code
  • Netbeans for C/C++ Development. ...
  • Code::Blocks. ...
  • Eclipse CDT(C/C++ Development Tooling) ...
  • CodeLite IDE. ...
  • Bluefish Editor. ...
  • Brackets Code Editor. ...
  • Atom Code Editor. ...
  • Sublime Text Editor.

Feel free to drop your comments and suggestions.. 




No comments:

Post a Comment

Popular Posts