C Program to find area of scalene triangle

For a better understanding, we always recommend you to learn the basic topics of C programming listed below:

What is the scalene triangle?

In this c program, we have to find the area of a scalene triangle. The scalene triangle is a triangle in which they have three unequal sides. The triangle that drawn at random would be scalene. The interior angles of the scalene triangle are always different since they have unequal sides.

In this c program, we need to find the triangle area, given the sides and angle. Normally we used to calculate the area of a scalene triangle using the equation, 'a = 1/2*base*height'. Here we are using a well-known formula and applying it in this c program. 

'Area = (s1 * s2 * sin((M_PI / 180) * angle)) / 2'.

How to implement area calculation of triangle in C

In this c program, we first accept the triangle sides; also, we recommend the user enter the triangle's angle, which we need to calculate the area. After getting the triangle's desired angle and sides, we apply our formula to calculate the triangle area. Here we are using the sin angle to find the area of the triangle. After calculation of the area, display the output of the c program using the float data type.


STEP 1: Include the header files to use the built-in functions into the C program.

STEP 2: Declare the variable s1, s2, angle as integer, and area as a Float.

STEP 3: Accept the side1 of a triangle into the variable s1.

STEP 4: Accept the side2 of a triangle into the variable s2.

STEP 5: Accept the angle of the triangle into the variable angle.

STEP 6: Calculate area=s1 * s2 * sin((M_PI / 180) * angle)) / 2

STEP 7: Display area of the Scalene triangle as area and return.

C Source Code


int main() {
  int s1, s2, angle;
  float area;
  printf("\nEnter Side1 : "); /* accepting the side of triangle */
  scanf("%d", & s1);
  printf("\nEnter Side2 : ");
  scanf("%d", & s2);
  printf("\nEnter included angle : "); /* accepting angle of triangle */
  scanf("%d", & angle );
  area = (s1 * s2 * sin((M_PI / 180) * angle)) / 2; /* calculating area using formula */
  printf("\nArea of Scalene Triangle : %f", area); /* printing the output */
  return (0);


Enter Side1 : 3
Enter Side2 : 4

Enter included angle : 30
Area of Scalene Triangle : 3.000000