i am trying to training my self to use functions and i start with easy tasks but i though that this task will work but the output is not show any result any idea why ?
this is the task ....
my code
Code:
#include<stdio.h>
#include<math.h>
#define PI 3.14
double deg_to_radians (double t);
double length_third_side (double n1,double n2,double tr);
double calculateArea(double s,double n1,double n2, double n3 );
int main ()
{
double n1,n2,n3,r,t,tr,s,a;
printf("Enter the length of side 1 [cm] :\n" );
scanf("%lf",&n1);
printf("Enter the length of side 2 [cm] :\n");
scanf("%lf",&n2);
printf("Enter the angel in degrees bettween side1 and side 2:");
scanf("%lf",&t);
tr= deg_to_radians (t);
n3= length_third_side (n1,n2,tr);
s=(n1+n2+n2)/2.0;
a= calculateArea(s,n1,n2,n3);
printf ("The area of the triangle = %.2lf ",a);
return 0;
}
double deg_to_radians (double t){
double tr ;
tr = t*PI/180.0;
return tr;
}
double length_third_side (double n1,double n2,double tr){
double n3;
n3 =n1*n1*n2*n2-(2*n1*n2*cos(tr));
return n3;
}
double calculateArea(double s,double n1,double n2, double n3 ){
double a;
a=sqrt(s*(s-n3)*(s-n1)*(s-n2));
return a ;
}