Tuesday, 17 March 2015

Find Area of Scalene Triangle

#include<stdio.h>
#include<math.h>
 
int main() {
   int s1, s2, angle;
   float area;
    printf("\nEnter Side1 : ");
   scanf("%d", &s1);
    printf("\nEnter Side2 : ");
   scanf("%d", &s2);
   printf("\nEnter included angle : ");
   scanf("%d", &angle);
   area = (s1 * s2 * sin((M_PI / 180) * angle)) / 2;
   printf("\nArea of Scalene Triangle : %f", area);
   return (0);
}

Output :

Enter Side1 : 3
Enter Side2 : 4
Enter included angle : 30
Area of Scalene Triangle : 3.000000 
 

Area of Scalene Triangle

C Program to find Area of Scalane Triangle

Properties of Scalene Triangle :

  1. Scalene Triangle does not have sides having equal length.
  2. No angles of Scalene Triangle are equal.
  3. To calculate area we need at least two sides and the angle included by them.

Formula to Find Area of Scalene Triangle :

Explanation and Program Logic :

Part 1 : M_PI

  • It is Constant defined in math.h Header File
  • It contain value = 3.14 in short instead of writing 3.14 write directly M_PI.

Part 2 : ( M_PI / 180 ) * angle

  • We are accepting angle in degree.
  • C function sin takes argument in radian , so to convert angle into radian we are purposefully writing above statement.

Part 3 : sin function

  • It computes sine of an angle
 

1 comment: