About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Tuesday, August 27, 2013

C Program to Find Area of Scalene Triangle


#include<stdio.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

C Program for Beginners : 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

sin((M_PI/180)*angle)
  • 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

No comments: